首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uwsgi IOError:写入错误

uwsgi IOError:写入错误
EN

Stack Overflow用户
提问于 2016-01-13 13:54:23
回答 2查看 27.9K关注 0票数 33

我的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秒的超时时间。知道为什么会发生这种事吗?

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-11-02 08:36:32

问题是客户端中止连接,然后Nginx在不通知uwsgi中止的情况下关闭连接。然后,当uwsgi返回结果时,套接字已经关闭。Nginx在日志中写入499个错误,uwsgi抛出一个IOError。

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

将uwsgi_ignore_client_abort放入您的nginx.config中。

代码语言:javascript
复制
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)

票数 38
EN

Stack Overflow用户

发布于 2018-06-08 09:54:11

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

代码语言:javascript
复制
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true

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

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34768527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档