微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

uwsgi OSError消息过多

如何解决uwsgi OSError消息过多

使用uwsgiNginx运行Django 3 python 3.6应用程序会抛出太多此类错误!我花了太多时间试图解决这个问题,因此欢迎您提供帮助。

它们绝对不是客户端断开连接。在网上查找时,我发现许多uwsgi ini配置并尝试了许多配置,但无济于事。其中大多数是来自没有业务访问该网站的国家/地区的HEAD请求,但也有许多正常请求也遇到此错误。消息看起来像这样:

Uwsgi日志:

Tue Sep 22 08:52:16 2020 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip x.xx.xx.xx) !!!
Tue Sep 22 08:52:16 2020 - uwsgi_response_writev_headers_and_body_do(): broken pipe [core/writer.c line 306] during GET / (x.xx.xx.xx)
OSError: write error
[pid: 9852|app: 0|req: 6262/18763] x.xx.xx.xx () {46 vars in 981 bytes} [Tue Sep 22 08:52:15 2020] GET / => generated 0 bytes in 313 msecs (HTTP/1.1 200) 7 headers in 0 bytes (0 switches on core 0)

Nginx访问日志:

x.xx.xx.xx - - [22/Sep/2020:08:52:16 +0200] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (iPhone; cpu iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML,like Gecko) Version/13.1.2 Mobile/15E148 Safari/604.1"

用户不可能仅在这313毫秒内尝试逃脱该站点。 这是ini当前运行的最低版本:

[uwsgi]
uid=www-data
gid=www-data
project=mysite
chdir=/home/myuser/releases/mysite-website/web
plugin=python36
wsgi-file=mysite/wsgi.py
daemonize=/home/myuser/logs/uwsgi/mysite-website.log
home=/home/myuser/releases/venv
processes = 1
enable-threads = true
socket=/var/run/uwsgi/app/mysite/socket.sock
pidfile=/var/run/uwsgi/app/mysite/project-masterpid
vacuum = true
touch-reload=/home/myuser/releases/mysite-website/web/mysite/wsgi.py

Nginx

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

uwsgi_pass unix:///var/run/uwsgi/app/mysite/socket.sock;
include uwsgi_params;
uwsgi_param HTTPS on;
uwsgi_param UWsgi_SCHEME https;
uwsgi_read_timeout 60s;

uwsgi_params:

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。