Optimal Idle timeout value in AWS ALB for a socket.io server #4076
-
I have some EC2 machines running socket.io servers/applications (they use the Before, I had the value of Idle timeout in ALB set to 60 seconds. But, sometimes my socket.io client connections/requests were receiving 504 Gateway Timeout and/or 400 Session Id Unknown errors, and it led my socket connections on the browser to disconnect and reconnect again. Later, I increased the value of Idle timeout from 60 seconds to 300 seconds. Now, interestingly, it seems the errors mentioned above have disappeared. I am worrying why 60 seconds are not enough for socket.io handshakes (for some of them) and getting a timeout. Or is it something normal to have such a long handshake time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Later I figured out that this question is not valid. Because socket.io has a configurable option |
Beta Was this translation helpful? Give feedback.
Later I figured out that this question is not valid. Because socket.io has a configurable option
pingInterval
and with this you can tweak the interval in such a way that it should be less than the idle timeout in your ALB. For example, if the idle timeout is 60 seconds, you can set thepingInterval
to some value less than 60 seconds, i.e 45 seconds. Then you will never get the errors mentioned above.