-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket.io-client 4.8.0 automatic reconnect is not working #5197
Comments
We're also seeing that it doesn't automatically reconnect when the transport is broken using websockets. |
Is it possible for you to create a minimal repo that simulates the issue? @sruetzler |
Hi. Just commenting here so I get further notifications as this potentially affects our product. In the mean time we locked And due to the new Thanks. |
I tried to reproduce this in a short example. But until now could not reproduce it. |
We initialise the io client like this; {
auth: xxx,
transports: ['websocket', 'polling'],
withCredentials: true,
reconnectionDelay: 100,
reconnectionDelayMax: 1000,
rememberUpgrade: true,
closeOnBeforeunload: true
}; And then observe that if you e.g. kill the backend server, it will simply not attempt to reconnect, even though it should based on the docs. |
this.client.on('connect_error', (error) => {
// If this is active it indicates a transient issue and it will try to reconnect
if (TypeUtils.isFalse(this.client?.active)) {
this.logger.warning(`[SocketClient] Connection error occurred: ${error.message}`, {
error
});
this.client.io.connect();
return;
}
this.logger.error(`[SocketClient] Transient connection error occurred: ${error.message}`, {
error
});
} We based the conclusion that the socket should try to automatically reconnect since we had this listener function on the None of the below listener function were ever triggered when the backend was killed and the above mentioned transient connection error log was triggered: client.io.on('reconnect_attempt', () => {
this.logger.info('[SocketClient] Initiating attempt to reconnect to socket...');
});
client.io.on('reconnect', (attempt) => {
this.logger.info(`[SocketClient] Reconnected after ${attempt} attempts`);
});
client.io.on('reconnect_failed', () => {
this.logger.error('[SocketClient] Reconnection failed after allotted attempts');
});
client.io.on('reconnect_error', (error) => {
this.logger.error(`[SocketClient] Reconnection error: ${error.message}`, error);
}); |
I am also facing this issue. It's pretty major since our "online users" counter just drops to 0 anytime we push updates to our code base. I think going back to 4.7.5 is the move for now |
Hi everyone, sorry for the delay. I was not able to reproduce the issue:
"No transports available" suggests the |
I would need some additional information. Does it happen with the client bundle? Or with a bundler (webpack, rollup, ...)? In that case, could you please provide your configuration? Does it happen randomly? Always? Does it happen in all browsers? Thanks in advance. |
Hey @darrachequesne
Here's how our frontend connects export const socket = io(SOCKET_SERVER_URL, {
autoConnect: false,
transports: ["websocket"], // <--- Could it related be this?
timeout: 10000,
auth: (callback) => {
const token = getToken()
if (token ) {
callback({
token,
});
} else {
console.log("No token found when trying to connect to Socket");
}
},
parser: customParser, // <--- We're using socket.io-msgpack-parser here
}); |
Describe the bug
I have a client which connects to server
If the server stops and restarts the connect event is not called anymore
In version 4.7.5 the connect event was called when the server restarts and opens the websocket
Socket.IO client version:
4.8.0
Expected behavior
The connect event should be called automatically if the server restarts and opens the websocket
Platform:
NodeJs 16 on Ubuntu 20.04
and also in Chromium 128.0.6613.119
Additional context
On 4.7.5 I get multiple times this connect_error event until it reconnects.
on 4.8.0 I get this errror once and after that I get this endless
The text was updated successfully, but these errors were encountered: