Get connection status on Socket.io client

后端 未结 5 1790
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 10:50

I\'m using Socket.io, and I\'d like to know the status of connection to the server from the client-side.

Something like this:

socket.status // return         


        
5条回答
  •  执念已碎
    2020-12-23 11:34

    @robertklep's answer to check socket.connected is correct except for reconnect event, https://socket.io/docs/client-api/#event-reconnect As the document said it is "Fired upon a successful reconnection." but when you check socket.connected then it is false.

    Not sure it is a bug or intentional.

提交回复
热议问题