Difference between pingInterval: 1000 and setInterval(1000) for recovery #4993
Unanswered
minchanhan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi!
The
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://socket.io/docs/v4/connection-state-recovery#usage,
https://codesandbox.io/p/sandbox/github/socketio/socket.io/tree/main/examples/connection-state-recovery-example/esm?file=index.js
I'm following this doc and example to test out the connection state recovery feature in socket.io but I'm confused because I thought socket.io handled ping pong emits automatically, so I figured setting pingInterval: 1000 would replace the line used in the example:
But the recovery isn't working when using:
without the setInterval...
With some digging I found that
socket.on("ping")
isn't triggered frompingInterval
like I expected. So do I still need this setInterval if I want to handle temporary reconnections rather than relying on pingInterval?:Beta Was this translation helpful? Give feedback.
All reactions