nginx、uwsgi日志IOError: write error

关于nginx:uwsgi IOError:写入错误
uwsgi IOError: write error
我的Django应用程序的nginx + uwsgi配置出现问题,我在uwsgi错误日志中不断收到此错误:

Wed Jan 13 15:26:04 2016 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 296] during POST /company/get_unpaid_invoices_chart/ (86.34.48.7)
IOError: write error

Wed Jan 13 15:26:20 2016 - uwsgi_response_write_headers_do(): Broken
pipe [core/writer.c line 238] during GET
/gestiune/print_pdf/nir/136194/ (89.122.255.186) IOError: write error

我没有收到所有请求的消息,但每分钟确实收到了几个消息。
我进行了搜索,并且了解到发生这种情况是因为nginx在uwsgi要写入响应时已关闭与uwsgi的连接。
这看起来很奇怪,因为在我的Nginx配置中,我有以下内容:

include uwsgi_params;
uwsgi_pass unix:/home/project/django/sbo_cloud/site.sock;
uwsgi_read_timeout 600;
uwsgi_send_timeout 600;
uwsgi_connect_timeout 60;

我确定出现错误的请求都没有超过600秒超时。
知道为什么会这样吗?

谢谢

问题是客户端中止连接,然后Nginx关闭连接而不告诉uwsgi中止。 然后,当uwsgi返回结果时,套接字已经关闭。 Nginx在日志中写入499错误,而uwsgi则抛出IOError。

非最佳解决方案是告诉Nginx不要关闭套接字,并等待uwsgi返回响应。

将uwsgi_ignore_client_abort放在您的nginx.config中。

location @app {
    include uwsgi_params;
    uwsgi_pass unix:///tmp/uwsgi.sock;

    # when a client closes the connection then keep the channel to uwsgi open. Otherwise uwsgi throws an IOError
    uwsgi_ignore_client_abort on;
}

目前尚不清楚是否可以告诉Nginx关闭uwsgi连接。 关于此问题还有另一个问题:(Propagate http abort/close from nginx to uwsgi / Django)

另一种解决方案是将以下设置放入uWSGI配置中:

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

参见https://github.com/getsentry/raven-python/issues/732

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值