我的django应用程序的nginx+uwsgi配置有问题,我一直在uwsgi错误日志中得到这个错误:
2016年1月13日Wed 15:26:04 - uwsgi_response_writev_headers_and_body_do():POST /company/get_company_invoices_core/ (86.34.48.7) IOError:写错误 2016年1月13日15:26:20 - uwsgi_response_write_headers_do():GET /gestiune/print_pdf/nir/136194/ (89.122.255.186) IOError:写错误
我没有得到他们所有的要求,但我确实得到了他们每分钟几个。我搜索了它,我知道这是因为nginx在uwsgi想要写响应时关闭了与uwsgi的连接。这看起来很奇怪,因为在我的nginx配置中,我有以下内容:
包括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秒的超时时间。知道为什么会发生这种事吗?
谢谢
发布于 2016-11-02 08:36:32
问题是客户端中止连接,然后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)
发布于 2018-06-08 09:54:11
另一种解决方案是在uWSGI配置中放置以下设置:
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = truehttps://stackoverflow.com/questions/34768527
复制相似问题