
Question:
I know reconnectionAttempts
is used for client side and pingTimeout
in socket io but I quite can't understand their use. Does pingTimeout mean that socket server will disconnect (I experimented, but it didn't) from client side?
I want to know about these two because one behaviour is solving my problem but I can't understand how it is happening. I think it may be related to above two options.
<strong>Behaviour:</strong> Whenever I close the socket on client side and then emit some event to server, it doesn't work, but after connecting it again, it fires just like it was waiting for the connection.
Does it mean if connection is not available, it will <strong>queue all pending events?</strong> (I observed this thing on client side, but not on server side. Is it true for server side too?)
Answer1:As the socket.io docs suggest,
<ul><li>pongTimeout
is the time in ms that the server will wait for a pong packet from client, before assuming the connection is dead and closing it.
reconnectionAttempts
is the number of times the client will try to connect to the server before giving up.
When you close the socket on client side, the server doesn't hear any pong
packet to it's ping
packets. By default the timeout is 60s. If you reconnect between this time, the connection will resume.