SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
292 stars 91 forks source link

Can't connect after disconnect #34

Closed defshift closed 8 years ago

defshift commented 8 years ago

I'm using socketcluster-client in a angular controller.

At first I try connect to the server and it's connected:

var options = {
  port: 8000
};
// Initiate the connection to the server
var socketInstance = socketCluster.connect(options);
socketInstance.on('connect', function () {
  console.log('connected');
});

then I try to disconnect on controller destroy event and it's disconnected:

$scope.$on('$destroy', function () {
  socketInstance.disconnect();
});

now I try to load controller again and connect to the server again to apply this code:

var options = {
  port: 8000
};
// Initiate the connection to the server
var socketInstance = socketCluster.connect(options);
socketInstance.on('connect', function () {
 console.log('connected');
});

server sees that connection was initiated, but 'connect' event doesn't work on the client side.

jondubois commented 8 years ago

@isotnikov The problem was that the second socketCluster.connect(options) was returning the previous socket (which is correct) but it wasn't being connected again (it stayed in a disconnected state). This was fixed in v4.3.2.