Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot close http server after connecting and disconnecting from a namespaced socket #474

Closed
pghalliday opened this issue Oct 3, 2012 · 0 comments

Comments

@pghalliday
Copy link

Another issue that i ran into while writing unit tests. It seems that after connecting and disconnecting from a namespaced socket the http server instance that exposes it can no longer be closed. In fact looking at the debug from socket.io it looks like the socket was not in fact disconnected. Here is code that reproduces the problem.

var io = require('socket.io');
var io_client = require('socket.io-client');
var http = require('http');

var server = http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello, world!');
});

var serverSocket = io.listen(server);
namespacedSocket = serverSocket.of('/namespaced');

server.listen(8080, function() {
  var clientSocket = io_client.connect('http://localhost:8080/namespaced');
  clientSocket.on('connect', function() {
    console.log('clientSocket connected');
    clientSocket.on('disconnect', function() {
      console.log('clientSocket disconnected');
      server.close(function() {
        console.log('Phew, everything\'s OK');
      });
    });
    clientSocket.disconnect();
  });
});

and here is the resulting console output.

   info  - socket.io started
   debug - client authorized
   info  - handshake authorized a_X19SkKc7wW6YmmjBcw
   debug - setting request GET /socket.io/1/websocket/a_X19SkKc7wW6YmmjBcw
   debug - set heartbeat interval for client a_X19SkKc7wW6YmmjBcw
   debug - client authorized for 
   debug - websocket writing 1::
   debug - client authorized for /namespaced
   debug - websocket writing 1::/namespaced
clientSocket connected
clientSocket disconnected
   debug - emitting heartbeat for client a_X19SkKc7wW6YmmjBcw
   debug - websocket writing 2::
   debug - set heartbeat timeout for client a_X19SkKc7wW6YmmjBcw
   debug - got heartbeat packet
   debug - cleared heartbeat timeout for client a_X19SkKc7wW6YmmjBcw
   debug - set heartbeat interval for client a_X19SkKc7wW6YmmjBcw

note that the disconnect does not seem to get to the server socket and that it continues to emit heartbeats.

@rauchg rauchg closed this as completed Nov 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants