[英]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.