Alex Rivera | Logout

force client disconnect from server with socket.io and nodejs

Asked 2011-02-19T01:24:09.180
145

Is there any way to disconnect a client with SocketIO, and literally close the connection? So if someone is connected to my server, and I want to close the connection between them and my server, how would I go about doing that?

Edit
Report

3 Answers

4

Assuming your socket's named socket, use:

socket.disconnect()
answered 2011-02-19T01:52:13.033
2

client._onDisconnect() should work

answered 2011-03-29T09:49:11.370
2

I'm using client.emit('disconnect') + client.removeAllListeners() for connected client for ignore all events after disconnect

answered 2012-06-07T06:29:21.873

Your Answer