title: WebSockets with nginx + uwsgi + flask-socketio
body: <p>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</p>
  
  <pre><code>WebSocket connection to 'ws://myserver.com/socket.io/?EIO=3&amp;transport=websocket&amp;sid=0514a0aa99f346e7ad717770f9911c89' failed: WebSocket is closed before the connection is established.
  </code></pre>
  
  <p>I have a feeling this is due to my uwsgi or nginx config.</p>
  
  <p>Here's the uwsgi config I'm using:</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>and here's the relevant portion of the nginx config:</p>
  
  <pre><code>    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;
      }
  </code></pre>
  
  <p>Is there an issue with using the</p>
  
  <pre><code>socket = /tmp/uwsgi.sock
  </code></pre>
  
  <p>from the uwsgi config with the </p>
  
  <pre><code>uwsgi_pass unix:/tmp/uwsgi.sock;
  </code></pre>
  
  <p>from the nginx config? Any help would be greatly appreciated. Of course, please let me know if I need to provide more information.</p>