Skip to content Skip to sidebar Skip to footer

How Do I Close A Sockjs Connection On The Server Side?

So, every time I refresh the page, it seems like sockjs is creating a new connection. I am saving every message to my mongodb on every channel.onmessage, so if I refresh my page 7

Solution 1:

Simply use .close:

if (connections[channelId][userId]) {
  // want to close the extra connection
  connections[channelId][userId].close();
} else {
  connections[channelId][userId] = conn;
}

Post a Comment for "How Do I Close A Sockjs Connection On The Server Side?"