Flask Socketio sockets fail to upgrade with multiple gunicorn workers & redis #1954
-
Hello, I have this issue where my socket clients are failing to upgrade. It happens at the start of the page load. If I give it time they'll eventually successfully upgrade. I also receive a lot of "Invalid Session" errors. If one connection is upgraded and another connection is in the error state I can close the upgraded connection and the errored connection will be upgraded. I recreated this issue on my test server without any emits being administered during the test. At its simplest form in my environment the issue can be recreated by creating a flask factory application, using redis, and using 2 gunicorn workers. Then simply open more connections than there are workers (3 in this test case). I use python 3.9 here because it works with eventlet. Here's the application init.py:
Here's the application file:
Here's the connection logs:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
In my production environment I run this setup with nginx. Here's my configs: sites-enabled app config:
nginx.conf:
|
Beta Was this translation helpful? Give feedback.
-
Are you reading the documentation? What you are doing is not supported. Gunicorn must always be started with one worker. https://flask-socketio.readthedocs.io/en/latest/deployment.html#gunicorn-web-server |
Beta Was this translation helpful? Give feedback.
Are you reading the documentation? What you are doing is not supported. Gunicorn must always be started with one worker. https://flask-socketio.readthedocs.io/en/latest/deployment.html#gunicorn-web-server