Socket.io: Document disconnect reasons

Created on 30 Oct 2017  路  9Comments  路  Source: socketio/socket.io

You want to:

  • [] report a bug
  • [x] request a feature

Current behaviour

No documentation.

Steps to reproduce (if the current behaviour is a bug)

Look at documentation.

Expected behaviour

It would be so great if there were some official documentation on the possible values for the "reason" value passed to the server side disconnect callback. Some I can discover on my own and make good guesses at ("ping timeout") but others are less clear ("transport close").

I'd like to try to handle some of them in different ways (and also for debugging purposes) but without knowing the possibilities or what they mean, it is rather difficult.

I have found:

  • "ping timeout": client stopped responding to pings in the allotted amount of time (per the pingTimeout config setting).
  • "transport close": this appears to happen if the client side stopped sending data at all... or maybe there's some kind of callback causing this to happen. I can see it happen if I just close a tab or follow a link from a page where I have an active connection to the server. But I'm not clear if this is always a case of the client causing it to happen.
  • "Client namespace disconnect": When the client sends a disconnect packet (client.disconnect())
    "server namespace disconnect": Looks to be when the server performs a socket.disconnect() action.
  • "Transport error": An error occurred, I assume this is a server side error, but I'm not totally clear, as I've not been able to trigger one on my own.

I'd be willing to do a pull request for the docs, but I am wary of adding in wrong/incomplete information without some further confirmation.

Most helpful comment

It looks like this documentation now exists here for anybody that gets to this issue from Google.

All 9 comments

I can`t find how to pass custom reason for disconnect or auth error

Any idea what could 'client error' reason mean?

Probably an error client side, I would guess some kind of uncaught js error that stopped js execution in the browser.

I've had a few also

  • "io server disconnect" This occurs using a third party library socketIOAuth when authentication fails

@Ra1da35ma "io server disconnect" is a more general disconnect reason. You will also get this when you just shut down your socket.io server, an error/exception forces your server to close, or just your code closes a connected socket

I need to know explicitly whether it is a timeout or an active closed connection. Your documentation is useful.

It looks like this documentation now exists here for anybody that gets to this issue from Google.

Thanks @c1moore guess we can close this then.

Sorry for re-opening the issue. Regarding the transport close that is the reason when page is closed/reloaded, it also happens some times in bad network conditions specifically when the ping packets are not delivered to the client. For the latter I need to handle it in the server side by waiting for the client to reconnect. Is there a way to properly distinguish between these two?

Was this page helpful?
0 / 5 - 0 ratings