`

flask_socketio + nginx + uwsgi + gevent + websocket实现稳定消息通讯

阅读更多
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
...



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics