uwsgi报错,前端返回504

前端返回504

 uwsgi报错日志问题1

Tue Jan 19 14:06:15 2021 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected)
BrokenPipeError: [Errno 32] Broken pipe(非正常关闭socket引发的错误)
broken pipe是send、write、writev时都有可能产生的错误,当一端在写另一端关闭了的连接的时候,就会产生broken pipe的错误。

uwsgi报错日志问题2

问题2
Fri Apr  2 17:43:17 2021 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /cross_server/update_version/ (ip 192.168.10.1) !!!
Fri Apr  2 17:43:17 2021 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /cross_server/update_version/ (192.168.10.1)
[ERROR][2021-04-02 17:43:17,212][setup.py:910]An un-handled exception was caught by salt's global exception handler:
OSError: write error
OSError: write error
OSError: write error

分析:

都是客户端中止连接,然后Nginx关闭连接而不告诉uwsgi中止。 然后,当uwsgi返回结果时,套接字已经关闭

解决方法

nginx配置添加参数

uwsgi_send_timeout 1800;        # 指定连接到后端uWSGI的超时时间。
uwsgi_connect_timeout 1800;     # 指定向uWSGI传送请求的超时时间,完成握手后向uWSGI传送请求的超时时间。
uwsgi_read_timeout 1800;        # 指定接收uWSGI应答的超时时间,完成握手后接收uWSGI应答的超时时间。

uwsgi配置添加参数  

ignore-sigpipe=true	#使uWSGI不显示SIGPIPE错误;
ignore-write-errors=true #使它不显示诸如uwsgi_response_writev_headers_and_body_do的错误;
disable-write-exception=true #防止 OSError写入时生成。

  

  

  

原文地址:https://www.cnblogs.com/lucktomato/p/15169028.html