Callback after reconnectionAttempts reached? #3976
-
I'm working on a project using Socket.io with React and Express. The site will display data to users that is periodically updated and I'm trying to account for any situation where the back end goes down. Rather than displaying stale data, I'd prefer to show an error message. I see that there's a So I assume there's something I'm not understanding about how these events work or how events in general work. Here's my current code:
I can get around the issue by setting a variable and a timeout on But that's pretty messy, so I'd like to have a callback that gets called automatically after |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Which version of Starting with v3, the socket instance no longer emits events related to reconnection attempts, you must use: socket.io.on("reconnect_attempt", function() {
console.log("reconnecting")
});
socket.io.on('reconnect_failed', function() {
console.log("reconnect failed");
}); Does that explain your issue? Reference: |
Beta Was this translation helpful? Give feedback.
Which version of
socket.io-client
are you using?Starting with v3, the socket instance no longer emits events related to reconnection attempts, you must use:
Does that explain your issue?
Reference: