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

Closing a server takes 25 seconds to clean up #494

Closed
josephg opened this issue Aug 30, 2011 · 2 comments
Closed

Closing a server takes 25 seconds to clean up #494

josephg opened this issue Aug 30, 2011 · 2 comments
Labels
bug Something isn't working

Comments

@josephg
Copy link

josephg commented Aug 30, 2011

The node.js process should terminate exactly 1 second after a client connects. Instead, it takes 26 seconds.

Given this server:

io = require 'socket.io'

s = io.listen 4321

s.sockets.on 'connection', (socket) ->
    console.log 'new connection'

    console.log 'client connected. Server will close in 1 second...'
    setTimeout (-> s.server.close()), 1000

... and this client:

io = require 'socket.io-client'

soon = (f) -> setTimeout f, 2000

client = io.connect 'http://localhost:4321'
client.on 'connect', ->
    console.log 'connected'
    soon ->
        client.disconnect()
        console.log 'disconnected'

.... this is what happens:

$ time coffee server.coffee 
   info  - socket.io started
   debug - client authorized
   info  - handshake authorized 21153209321339684377
   debug - setting request GET /socket.io/1/websocket/21153209321339684377
   debug - set heartbeat interval for client 21153209321339684377
   debug - client authorized for 
   debug - websocket writing 1::
new connection
client connected. Server will close in 1 second...
   debug - websocket received data packet 5:1+::{"name":"newListener","args":["connect"]}
   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 21153209321339684377
   debug - cleared close timeout for client 21153209321339684377
   debug - cleared heartbeat interval for client 21153209321339684377
   debug - discarding transport

real    0m26.230s
user    0m0.294s
sys 0m0.043s
@3rd-Eden
Copy link
Contributor

It's probably because we are still doing some garbage collection, but it should still close asap. Marked as bug so we can take a closer look at it.

@tk421
Copy link

tk421 commented Dec 27, 2011

I have an easy way to reproduce this problem. If you have an script with this two lines:

var io = require("socket.io").listen(2222);
io.server.close();

The port is closed (you can see it with netstat) but the node script does stop executing.

darrachequesne added a commit that referenced this issue Jul 8, 2024
This reverts commit 2c55b27, which breaks websocket transport under node v0.10 (#494).
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants