-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Socket connection gets timed out unexpectedly #580
Comments
Check that your ingress load balancer supports WebSockets and doesn't timeout long lived connections. Some cloud providers timeout connections after a few seconds by default. You may need to increase it. |
Thanks for the quick response @jondubois. I really appreciate it. But even if i disable the ping time out, that is |
Another possibility is that if your client and server major versions are different (especially those before v14 versus v15+), it can lead to timeout issues as the timeout message is different. In the older versions, the protocol used If you want to use new clients with old servers, you can run the latest client in compatibility mode. See https://github.com/SocketCluster/socketcluster#compatibility-mode |
I am using socketcluster-server on server side. On client side I use simple websocket to connect to server.
My connection parameters are-
let agOptions = { handshakeTimeout: 60000, pingInterval: 50000, pingTimeout: 90000 };
As seen in agOptions, pingTImeout is 90 seconds, which means that the connection should be alive even if there is no communication between client and server for 90s. On client side, I have a ping mechanism which sends ping at interval of 10 seconds in the format mentioned below.
{ "event":"#publish", "data":{ "channel":"some-channel", "data":{ "socketId":"", "event":"ping", "auth":"" } } }
The server responds to the ping by sending a pong in the below :
{ "event": "#publish", "data": { "channel": "some-other-channel-subscribed-by-client", "data": { "event": "pong", "message": "#2" } } }
I expect this mechanism to keep connection alive as the client and server and client communicate continuously.
This things works very well on localhost.
But when this is deployed on a kubernetes cluster, it gets disconnected after random intervals. Sometimes 40s other time 100s.
How do i fix it?
The text was updated successfully, but these errors were encountered: