uwsgi IOError:写入错误 [英] uwsgi IOError: write error

查看:93
本文介绍了uwsgi IOError:写入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 django 应用程序的 nginx+uwsgi 配置有问题,我不断在 uwsgi 错误日志中收到此错误:

I have a problem with my nginx+uwsgi configuration for my django app, I keep getting this errors in the uwsgi error log:

2016 年 1 月 13 日星期三 15:26:04 - uwsgi_response_writev_headers_and_body_do():POST/company/get_unpaid_invoices_chart/(86.34.48.7) 期间管道 [core/writer.c line 296] 损坏IOError:写入错误

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

2016 年 1 月 13 日星期三 15:26:20 - uwsgi_response_write_headers_do():损坏在 GET 期间管道 [core/writer.c line 238]/gestiune/print_pdf/nir/136194/(89.122.255.186) IOError: 写错误

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 配置中我有这个:

I am not getting them for all the requests but I do get a couple of them each minute. I searched for it and I understand that this happens because nginx closes the connection to uwsgi by the time uwsgi wants to write the response. This looks strange because in my nginx configuration I have this:

包含 uwsgi_params;

include uwsgi_params;

uwsgi_pass unix:/home/project/django/sbo_cloud/site.sock;

uwsgi_pass unix:/home/project/django/sbo_cloud/site.sock;

uwsgi_read_timeout 600;

uwsgi_read_timeout 600;

uwsgi_send_timeout 600;

uwsgi_send_timeout 600;

uwsgi_connect_timeout 60;

uwsgi_connect_timeout 60;

我确信出现错误的所有请求都没有超过 600 秒的超时时间.知道为什么会发生这种情况吗?

I am certain that none of the requests for which the error appears has exceeds the 600 seconds timeout. Any idea why this would happen?

谢谢

推荐答案

问题是客户端中止了连接,然后 Nginx 关闭了连接,而没有告诉 uwsgi 中止.然后当 uwsgi 返回结果时,套接字已经关闭.Nginx 在日志中写入 499 错误并且 uwsgi 抛出一个 IOError.

The problem is that clients abort the connection and then Nginx closes the connection without telling uwsgi to abort. Then when uwsgi comes back with the result the socket is already closed. Nginx writes a 499 error in the log and uwsgi throws a IOError.

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

The non optimal solution is to tell Nginx not to close the socket and wait for uwsgi to come back with a response.

将 uwsgi_ignore_client_abort 放在你的 nginx.config 中.

Put uwsgi_ignore_client_abort in your 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/从 nginx 关闭到 uwsgi/Django)

It is not clear if it is possible to tell Nginx to close the uwsgi connection. There is another SO questin about this issues: (Propagate http abort/close from nginx to uwsgi / Django)

这篇关于uwsgi IOError:写入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆