How can we force a reconnect for testing only #4611
-
I need a way to make sure that my function for reconnection is working. Is there a way that we can force a reconnection only for testing purposes? client
Then on the server some code to force reconnect so that we can make sure the reconnect stuff in the client run correctly |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes we can just do a quick restart on the server and that will cause a reconnect however I collect data logs and by doing a quick connect my data logs stop as well. It would be nice if we could call an ````emit("test-reconnect") to cause only that client emitting to reconnect. |
Beta Was this translation helpful? Give feedback.
-
Hi! You can close the underlying engine: const socket = io();
socket.on("connect", () => {
setTimeout(() => {
if (socket.io.engine) { // might be undefined if the client is not connected
socket.io.engine.close();
}
}, 5000);
}); |
Beta Was this translation helpful? Give feedback.
Hi! You can close the underlying engine: