Replies: 3 comments 2 replies
-
You say that you are using the nginx config from the Flask-SocketIO, but that is incorrect. I'm not sure what's wrong with your config, but it is certainly different than the config in my documentation. So maybe you should copy my config and start from there? |
Beta Was this translation helpful? Give feedback.
-
I just redid some testing with gunicorn and it turns out that even when connecting directly to the gunicorn server (no nginx as reverse proxy) there is some issue with flask-socketio. When I connect straight to the gunicorn server, the "failed: WebSocket is closed before the connection is established." actually shows up a lot, like the client tries to connect to the socket a lot of times. Eventually, the connection goes through and the app works correctly for a while, until the connection drops and starts presenting the same error messages again... I can't figure out why this would happen, do you have any idea where to look @miguelgrinberg? Some infos about my project:
|
Beta Was this translation helpful? Give feedback.
-
I think you've already solved this problem, buddy. But perhaps this will be useful to someone else.
After I set the number of workers to 1 the problem disappeared. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am having trouble deploying my app to production. Everything works fine in my development, yet once I deploy to my server, the page cannot connect to the socket and displays the following message:
"WebSocket connection to 'wss://<domain_name>/socket.io/?EIO=4&transport=websocket&sid=2Xv-b8hcnYSe6MlIAAEe' failed: WebSocket is closed before the connection is established. value @ websocket.js:138"
I was worried it might be due to TLS, so I also tested the page in http, obtaining the same error:
"WebSocket connection to 'ws://<domain_name>/socket.io/?EIO=4&transport=websocket&sid=kilk1saF4Ik0G-3TAAFh' failed: WebSocket is closed before the connection is established."
I have determined that the issue comes from nginx by exposing gunicorn to the web and checking that the site works correctly there. I ran:
gunicorn --bind 0.0.0.0:5010 --worker-class eventlet -w 3 wsgi:application
And changed the socketio address in the webpages js to include the :5010 port. This configuration worked correctly and the site could be used normally. Therefora, the error must be in the nginx proxying
I have checked discussions here and in stack overflow and tried to implement all sugestions. My server is configured using the nginx configuration recommended in the flask-socketio documentatio:
Beta Was this translation helpful? Give feedback.
All reactions