-
Notifications
You must be signed in to change notification settings - Fork 571
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
xhr-polling connections are never closed #178
Comments
Not sure if this also happening for other transports like WebSockets etc. |
This is not a good idea since the socket could be re-used by the browser for other requests. |
@guille leaving the server spinning because it has unanswered requests isn't good either. |
CPUs won't actually be spinning, it'll just wait on I/O. It's the responsibility of the client to sever the connection if it wants On Wednesday, July 3, 2013, Arnout Kazemier wrote:
Guillermo Rauch |
@guille this PR seems legit to me. Wouldn't leaving the socket open cause more harm than good? |
@c4milo no because node should clean it up. If you look at the "Hello World" of node: you never actually close the socket yourself, and the server is keep-alive compliant out of the box. Engine.IO shouldn't "take over" the socket necessarily. We could make it an option, for example if you plan on having a dedicated domain for engine.io |
Nodejs cleans it up after 2 minutes which is the timeout by default for idle sockets. If you don't close the socket and your server has too many concurrent connections, you might run out of file descriptors too soon, even if your clients are closing the connections upon disconnections. Another scenario, from of the top of my head, that might not work reliably is when you want to support presence, you might see clients connected when in reality they are not. |
@guille - perhaps I'm missing something but in this case the client sent a 'close' packet - thus the client's intent is pretty much clear - no? It just seems like the benefit of keeping the socket open versus closing it is rather small - i.e. the real-time issue pointed out by @c4milo, memory consumption, etc. Thoughts? |
@mokesmokes keep in mind the engine.io socket does not equal TCP socket. The browser could continue to use the TCP socket for other requests that are NOT captured by engine.io. The close packet is clear in the intent of closing the engine.io socket, which is why we fire Like I said, the improvement we could make here is to enforce the TCP close if the user desires that. But that behavior must be opt-in. |
@guille - here's a scenario: in a mobile app (both Android & iOS) - the app frequently voluntarily disconnects. For example - any time the home button is clicked, screen locked, etc. This is a requirement since any I/O in this state may crash the app. We then reconnect when the app is re-focused. So potentially there will be loads of zombie sockets hanging around. Perhaps the solution is to have the standard 'close' as you have today, but also add an additional 'hardClose' client command - which can be used when required? (e.g. the scenario described above) |
|
I hope we have a deal ;-) |
**You can test it by yourself using chrome://net-internals/#sockets |
Sure but closing the socket would incur in an entire roundtrip to set it up again if the browser needs to extend the pool |
sure, I just don't think that default behavior is intuitive and legit for non xhr-polling cases. If anything, it will be seen as an issue instead. |
Anyway, I'm fine with having it as an opt-in :) Thank you @guille |
@guille |
@kapouer - it should be left up to the developer. You're right that if the code is engine.listen then the default should be true, but also in cases where it's attached to the http server it may be true (application dependent) - e.g. my scenario above (which is what I'm doing BTW). |
Emit errors thrown by xhr.send()
I've found this bug while I was writing primus. When a client calls the close method a simple
close
type packet is send to the server. The server only calls aself.onClose
function but never actually closes the accepted connection (s) causes theserver.close
call to hang indefinitely.Pull request is coming.
The text was updated successfully, but these errors were encountered: