一、问题现象和日志报错

  之前在项目实现了excel导入导出:django导入导出excel实践,之前一直稳定运行,突然得知导出用户信息时出现nginx错误报告:

  

  查看nginx日志,报错信息如下所示:

upstream timed out (: Connection timed out) while reading response header from upstream, client: 119.157.163.211, 
server: localhost, request: "GET /xxxxx/export/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:7080", host: "xxxx.com:8100", referrer: "http://xxxxx.com:8100/xxxxxxx/"

  查看uwsgi日志,报错信息如下所示:

Tue Jul  ::  - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /stark/crm/customer/export/ (ip 113.57.163.211) !!!
Tue Jul :: - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line ] during GET /stark/crm/customer/export/ (113.57.163.211)
OSError: write error

二、解决方法

1、调整uwsgi配置

  ignore-singpipe 使uWSGI不显示SIGPIPE错误;

  ignore-write-errors 使它不显示诸如uwsgi_response_writev_headers_and_body_do的错误;

  disable-write-exception 防止 OSError写入时生成。

  因此在uwsgi.ini中添加如下配置:

ignore-sigpipe=true
ignore-write-errors=true
disable-write-exception=true

  配置添加后,uwsgi日志中不再显示错误信息。

2、调整nginx配置

  一开始是调大了nginx的超时参数设置:

proxy_connect_timeout           ;
proxy_read_timeout ;
proxy_send_timeout ;

  没有产生作用nginx依然报错。

  proxy_read_time针对的是反向代理转发的超时,不针对uwsgi超时,因此需要在nginx配置中添加如下参数:

uwsgi_send_timeout ;        # 指定连接到后端uWSGI的超时时间。
uwsgi_connect_timeout ; # 指定向uWSGI传送请求的超时时间,完成握手后向uWSGI传送请求的超时时间。
uwsgi_read_timeout ; # 指定接收uWSGI应答的超时时间,完成握手后接收uWSGI应答的超时时间。

  重启nginx后,excel导出正常。

  

最新文章

  1. android studio/Intellij idea之proguard实践
  2. 深度学习入门教程UFLDL学习实验笔记三:主成分分析PCA与白化whitening
  3. C# 如何调用WebServer函数
  4. opencv--图像轮廓检测
  5. android 多布局
  6. Java遇见HTML——JSP篇之JavaBeans
  7. 将项目初始化到git服务器
  8. Python学习笔记一--字符串的使用
  9. asp.net:验证控件中ValidationExpression的写法
  10. C语言预处理指令
  11. 鸟哥Linux私房菜知识点总结6到7章
  12. JS进阶 ] 分析JS中的异步操作
  13. 【译】最大限度地降低多线程 C# 代码的复杂性
  14. jenkins使用1----初始化设置
  15. WC2017游记 & 能力残废康复计划
  16. 中国剩余定理模板 51nod 1079
  17. Dubbo学习笔记5:Dubbo整体框架分析
  18. [译]async/await中使用阻塞式代码导致死锁 百万数据排序:优化的选择排序(堆排序)
  19. mysql在命令行模式下创建数据库时要显式指定字符集
  20. 2-string相关函数

热门文章

  1. MySQL 数据库中删除重复数据的方法
  2. CSS选择器[attribute | = value] 和 [attribute ^ = value]的区别
  3. 阿里OSS 渗透案例
  4. 2019.10 搜索引擎最新排名,Elasticsearch遥遥领先
  5. Asp.Net或WebAPI获取表单数据流(批量文件上传)
  6. C#进阶之路(八)集合的应用
  7. RabbitMQ、RPC、SaltStack "贡"具的使用
  8. ios路线
  9. fetch的常见问题及其解决办法
  10. 基于hashlib下的文件校验