Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有太多uwsgi OSError消息_Python_Django_Nginx_Uwsgi_Oserror - Fatal编程技术网

Python 有太多uwsgi OSError消息

Python 有太多uwsgi OSError消息,python,django,nginx,uwsgi,oserror,Python,Django,Nginx,Uwsgi,Oserror,用uwsgi&nginx运行django3python3.6应用程序会抛出太多的错误!我花了太多的时间试图弄明白,所以欢迎任何帮助 它们绝对不是客户端断开连接。在线查看时,我发现了许多uwsgi ini配置,并尝试了其中的许多配置,但均无效。其中大多数是来自一个没有业务访问该网站的国家的HEAD请求,但也有许多正常请求也会遇到此错误。这些消息如下所示: Uwsgi日志: Tue Sep 22 08:52:16 2020 - SIGPIPE: writing to a closed pipe/so

用uwsgi&nginx运行django3python3.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_参数:

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;

我可能已经解决了一个类似的问题,将这个答案中提到的三个选项添加到我的.ini配置文件中。也可能对您有所帮助: