B
B
bumbay2014-09-16 20:35:10
Node.js
bumbay, 2014-09-16 20:35:10

How to disconnect connection in socket.io and then reconnect?

I am writing an application in AngularJS, it is necessary to disconnect the connection when the user logs out, and create a new one when the user logs in again.
I did it like this, when I exit I execute:
socket.socket.disconnect();
And I clear the socket variable.
But when I log in, the connection is not established.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bumbay, 2014-09-16
@bumbay

Almost undocumented socket.io leads to a long time to solve various problems.
Solution found on a great site .

// 0.9  socket.io version
io.connect(SERVER_IP, {'force new connection': true});

// 1.0 socket.io version
io.connect(SERVER_IP, {forceNew: true });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question