Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created October 17, 2011 10:16
Show Gist options
  • Save ppcano/1292336 to your computer and use it in GitHub Desktop.
Save ppcano/1292336 to your computer and use it in GitHub Desktop.
Socket.io and Socket.io-client in Expresso Serial Tests will be hanged.
test: function( done ) {
var port = 8080,
io = require("socket.io").listen(port);
io.set('polling duration', .2);
var client = require("socket.io-client").connect( "http://localhost", { port: port });
client.on('connect', function() {
client.disconnect();
});
client.on('disconnect', function() {
console.log(' client disconnect');
client.socket.transport.websocket.finishClose();
io.server.close();
done();
});
},
@ppcano
Copy link
Author

ppcano commented Oct 17, 2011

info - socket.io started
debug - client authorized
info - handshake authorized 15148061181922540821
debug - setting request GET /socket.io/1/websocket/15148061181922540821
debug - set heartbeat interval for client 15148061181922540821
debug - client authorized for
debug - websocket writing 1::
client disconnect
finish close ppcano
debug - websocket received data packet 0::
debug - got disconnection packet
info - transport end by forced client disconnection
debug - websocket writing 0::
info - transport end
debug - set close timeout for client 15148061181922540821
debug - cleared close timeout for client 15148061181922540821
debug - cleared heartbeat interval for client 15148061181922540821
debug - discarding transport

@pokoli
Copy link

pokoli commented Oct 30, 2011

HI, i've got similar code, but i could not get the same result as you. Could you give me advice about what i'm doing wrong?. The code is on https://gist.github.com/1325853. Running on expresso i've got the folloing result:
info - socket.io started

And it remains here, till i press control+C and I get the following:

^C
100% 1 tests

Thanks in advance.

@ppcano
Copy link
Author

ppcano commented Oct 31, 2011

i answered this question here: http://stackoverflow.com/questions/5965733/how-does-one-properly-shutdown-socket-io-websocket-client

Also, it could be that you are running your tests with the proper arguments:

  1. run serial tests ( normally, the convention is to use 'done' instead of 'beforeExit' with is the term for no-serial tests ),

  2. -t TIMEOUT, with a timeout big enough in order the tests won't fail because timing-out.

--> expresso mytest -s -t 10000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment