Reputation: 137
I'm currently using nginx + uwsgi + flask.
I'm using SSE from flask to get real time message from server to client (like one way socket).
but, since I set process = 10
, only 10 connection can be made.
once all process is busy, the new connect is hanging, and then got error (like net::ERR_NETWORK_CHANGED
).
and this will break all other connection in the process with this error
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /stream !!!
uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during GET /stream
OSError: write error
Client disconnected.
I want to show waiting page if all process is busy.
I've been trying to solve this issue, but I'm really hard for me...
[uwsgi]
vhost=true
chdir=/Server/
#venv=/Server/venv
module = app:app
callable = application
master = true
processes = 10
socket = /tmp/uwsgi.sock
; http-socket = 0.0.0.0:8000
chmod-socket = 666
vacuum = true
die-on-term = true
enable-threads = true
wsgi-file = /Server/wsgi.py
;pythonpath = /Server/venv/lib/python3.10
logto = /Server/uwsgi.log
log-reopen = true
listen = 10 # No additional connections will be queued
# Increase timeouts
socket-timeout = 3600
harakiri = 3600
http-timeout = 3600
# Optional: Adjust buffer size if needed
buffer-size = 65535
this is my uwsgi.ini file.
server {
listen 80;
client_max_body_size 50M;
location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock; # Use the uWSGI socket
uwsgi_read_timeout 600;
uwsgi_send_timeout 600;
uwsgi_connect_timeout 60;
proxy_buffering off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_cache off;
# CORS settings
# add_header 'Access-Control-Allow-Origin' '*' always;
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
# add_header 'Access-Control-Allow-Headers' 'Authorization, Origin, X-Requested-With, Content-Type, Accept' always;
# Handle OPTIONS requests
#if ($request_method = 'OPTIONS') {
# add_header 'Access-Control-Allow-Origin' '*';
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# add_header 'Access-Control-Allow-Headers' 'Authorization, Origin, X-Requested-With, Content-Type, Accept';
# return 204;
#}
error_page 403 502 503 504 /error.html;
proxy_intercept_errors on;
proxy_next_upstream error timeout invalid_header http_503;
proxy_next_upstream_tries 1;
}
location = /error.html {
root /Server/static;
internal;
}
}
and this is my nginx default.conf.
so, I have 2 questions.
please help me T^T
Upvotes: 0
Views: 34