Client side error handling on server shutdown #4116
-
Hi, I am failing at proper error handling on the client side in case of an unexpected shutdown of the server. As soon as the server suddenly disappears, I receive one disconnect event and after that a constant stream of net:ERR_CONNECTION_REFUSED (polling-xhr.js @199). Is there a way to handle these errors in my code? It doesn't seem like I get one of the error handling events (error, reconnect_error, reconnect_failed). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can listen to the events emitted by the socket object: socket.on("connect", () => {
// ...
});
socket.on("connect_error", () => {
// ...
});
socket.on("disconnect", () => {
// ...
}); Reference: https://socket.io/docs/v4/client-socket-instance/#events That being said, Reference: https://socket.io/docs/v4/logging-and-debugging/#error-logs-in-the-browser-console |
Beta Was this translation helpful? Give feedback.
You can listen to the events emitted by the socket object:
Reference: https://socket.io/docs/v4/client-socket-instance/#events
That being said,
net:ERR_CONNECTION_REFUSED
errors are managed by the browser itself, we have no control over them and cannot silence them...Reference: https://socket.io/docs/v4/logging-and-debugging/#error-logs-in-the-browser-console