I am using socket.io,can I detect the disconnect reason from disconnect event ? I can see in log files like this
info: transport end (booted) info: transport end (close timeout) info: transport end (error)
I want to get the reason (booted,close timeout,error) I will use like this:
socket.on('disconnect', function(){
console.log('User 1 disconnected because '+reason);
});
Can I get the reason ?
EDIT:I found the solution
socket.on('disconnect', function(reason){
console.log('User 1 disconnected because '+reason);
});
Socket disconnects automatically, reconnects, and disconnects again and form a loop. #918.
The error message “ERR_SOCKET_NOT_CONNECTED” is instantly solved in the majority of the cases when we flush the sockets on your browser. This will break the connection between any active pages on your browser and you might have to reinitialize everything.
socket.on('disconnect', function(reason){
console.log('User 1 disconnected because '+reason);
});
This is the solution.
Possible reasons for disconnect are now documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With