-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeouts after 10 mins with error code 1006 #7
Comments
This could be the browser closing the socket due to inactivity. The WebSocket protocol has a ping/ping mechanism, but most browsers do not implement it. The server implements the pong message right now, but it does not send pings to clients (though I've been considering adding this). What most people do is just send a dummy message every 50 seconds or so to keep them from timing out (I believe some browsers timeout sockets at one minute). |
Thanks for the suggestion. As it happens I managed to fix the issue with this: https://stackoverflow.com/questions/19304157/getting-the-reason-why-websockets-closed-with-close-code-1006/57706152#57706152 |
@imrankhan17 I'm not sure that's the best solution, because making the nginx timeouts longer will (I think) affect your non-websocket routes as well. As I said above, the best to beat timeouts is to have a little interval function in the browser that sends a dummy package regularly. |
I have a separate nginx config for this websocket route so that shouldn't be an issue. With your suggestion, do you mean it's the client's responsibility to send dummy messages or can I do the same from the server too? |
It does not matter who sends the packet, the only purpose is to keep some traffic in the line to prevent the timeouts. I suggested you do it from the client because it is easier. I was considering adding pings in the server as a definitive solution to this problem. |
Ok great, I'll look into adding in the pings but it'd be great if you added it into the package too. |
Yes, keeping this issue open so that I don't forget! |
@miguelgrinberg Is this something that you are working on ? I was thinking adding an option in initialization for enabling the ping and then checking on time in this code to send a ping. |
@sanhardik I haven't had time to look at this yet, but yes, doing this in the thread may be the best solution. |
I have a flask-sock app deployed using gunicorn and nginx. I get disconnected after 10 minutes (sometimes sooner) with the following error:
Disconnected (code: 1006, reason: "")
Is there a way to configure the timeout length?
I'm running it with:
gunicorn --bind 127.0.0.1:5655 --workers 4 --threads 20 wsgi:app
The text was updated successfully, but these errors were encountered: