Reputation: 418
I'm trying to establish a websocket connection using socket.io on the frontend and Flask-Socketio on the backend. However, the frontend is giving me the error
WebSocket connection to 'ws://myserver.com/socket.io/?EIO=3&transport=websocket&sid=0514a0aa99f346e7ad717770f9911c89' failed: WebSocket is closed before the connection is established.
I have a feeling this is due to my uwsgi or nginx config.
Here's the uwsgi config I'm using:
[uwsgi]
base = /var/www/webapp
file = %(base)/run.py
callable = app
pythonpath = %(base)
socket = /tmp/uwsgi.sock
chmod-socket = 666
http-websockets = true
gevent = 1000
processes = 1
threads = 2
enable-threads = true
single-interpreter = true
master = true
chdir = /var/www/webapp
fs-reload = %(base)/app/
touch-reload = %(base)/run.py
py-autoreload = 1
harakiri = 3600
and here's the relevant portion of the nginx config:
location /socket.io/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
Is there an issue with using the
socket = /tmp/uwsgi.sock
from the uwsgi config with the
uwsgi_pass unix:/tmp/uwsgi.sock;
from the nginx config? Any help would be greatly appreciated. Of course, please let me know if I need to provide more information.
Upvotes: 3
Views: 4032
Reputation: 877
You should change uwsgi_pass unix:/tmp/uwsgi.sock;
to uwsgi_pass unix:///tmp/uwsgi.sock;
.
Upvotes: 2