[英]BrokenPipeError: [Errno 32] Broken pipe error when running GANs
[英]error: [Errno 32] Broken pipe when running flask with nginx at localhost
我有一个Flask应用程序,将单独的socket.io服务器用于实时应用程序。 我在单独的端口上运行它们,并使用nginx在同一端口上对其进行测试。
upstream httpapp {
ip_hash;
server 127.0.0.1:7777;
}
upstream socketioapp {
ip_hash;
server 127.0.0.1:5555;
}
server {
listen 5000;
server_name localhost;
location / {
proxy_pass http://httpapp;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /socket.io {
proxy_pass http://socketioapp;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
在开发的最后半年中,此设置一直很好,直到一天,我一直无故收到此错误。 这是我访问localhost:5000时遇到的错误。
127.0.0.1 - - [13/Oct/2015 07:58:08] "GET /static/js/main.js HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53388)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 657, in __init__
self.finish()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 716, in finish
self.wfile.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 283, in close
self.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------
该错误仅发生在2.4MB静态javascript文件上 ,该文件在开发环境中为未压缩大小。 我知道静态文件很大,但之前一直运行良好。
最重要的发现-访问localhost:7777完全起作用。 但是,由于它需要实时功能,因此不适合测试应用程序。 想法是将flask应用程序和实时应用程序都放在同一端口上,并使用默认的socket.io init。 我没有尝试过的一件事是将socket.io设置更改为localhost:5555。
我正在使用带有flask_script样式配置的python manage.py runserver运行flask,因为它将所有目的用作开发环境。 (由于EC2正常运行,所以我没碰过生产环境,而且我不想惹麻烦。)引起我回想的唯一动作是将端口号从5000更改为80,然后运行nginx使用sudo。 听起来无关紧要,但这确实让我感到惊讶。
互联网上的研究时间仅解释了错误的定义,而没有解决方案。 我要采取什么行动才能接近解决这个问题?
我有一个Django应用程序,并且在过去两个月中遇到了相同的问题,但一直无法解决。
我刚刚将nginx.conf文件更新为:
proxy_read_timeout 400s;
根据http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout ,默认超时为60秒。 我将我的版本更新为400s。 到目前为止,效果很好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.