flask_socketio + nginx + uwsgi + gevent + websocket实现稳定消息通讯 socketnginxwebsocketuwsgiflask
程序员文章站
2022-07-12 16:34:22
...
1、nginx反向代理配置:
location /socket.io {
include uwsgi_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
uwsgi_pass 127.0.0.1:5000;
}
2、uwsgi ini文件配置:
[uwsgi]
socket = 127.0.0.1:5000
master = true
chdir =
wsgi-file =
processes = 1
stats = 127.0.0.1:9591
daemonize = /psd/logs/uwsgi.log
pidfile = uwsgi.pid
vacuum = true
callable = app
enable-threads = true
log-maxsize = 10000000
disable-logging = true
buffer-size=32768
http-websockets = true
gevent = 100
gevent-early-monkey-patch = true
3、flask_socketio 后台代码,网上一大堆
from flask_socketio import SocketIO, emit
...
location /socket.io {
include uwsgi_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
uwsgi_pass 127.0.0.1:5000;
}
2、uwsgi ini文件配置:
[uwsgi]
socket = 127.0.0.1:5000
master = true
chdir =
wsgi-file =
processes = 1
stats = 127.0.0.1:9591
daemonize = /psd/logs/uwsgi.log
pidfile = uwsgi.pid
vacuum = true
callable = app
enable-threads = true
log-maxsize = 10000000
disable-logging = true
buffer-size=32768
http-websockets = true
gevent = 100
gevent-early-monkey-patch = true
3、flask_socketio 后台代码,网上一大堆
from flask_socketio import SocketIO, emit
...