question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client don't reconnect after error event

See original GitHub issue

If I setup auth middleware function, that calls next with error, I get error event on the client, without further reconnection attempts.

And if I manually call socket.io.reconnect() on that error callback, nothing happens, because socket.io.readyState is open so reconnection doesn’t proceed.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
heroandtn3commented, Dec 8, 2014

Hi, this is my solution using manual reconnect that is introduced in version 1.2.0

socket.on('error', function (err) {
  if (err == 'not authenticated') {
    socket.disconnect();
    socket.io.opts.query = query; // replace with another authorization query
    socket.connect();
  } else {
    console.log('Connect error: ', err);
  }

});  
0reactions
heroandtn3commented, Dec 11, 2014

@Ajaxy I think it’s the same, my example is just a new way to manually reconnect that was introduced in version 1.2.0. In my example, I force client to disconnect before reconnect again with another query that I will be used in authorization middleware, it will avoid duplicate socket connections.

Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.io client can't connect/reconnect reliably - Stack Overflow
The question is, how does one reliably connect/reconnect and/or why don't I get additional connect events? Here's a sample console.log output:
Read more >
Client API - Socket.IO
Event : 'reconnect_error'​. error <Error> error object. Fired upon a reconnection attempt error. socket.io.on("reconnect_error", (error) => {
Read more >
Understanding and Handling Connection Lifetime Events in ...
The OnReconnected event handler in a SignalR Hub can execute directly after OnConnected but not after OnDisconnected for a given client.
Read more >
Disconnect Reasons and Error Messages - NetMotion
Error Code State of. Mobility Client Message /Description 1 Graceful disconnect 25 •Failover System is out of memory. 26 •Retry (reconnect) More data.
Read more >
Automatic client reconnection - IBM
If you set the MQCNO option, MQCNO_RECONNECT_Q_MGR , do not include other queue managers in the same queue manager group. The client returns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found