mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
This fixes an issue where multiple engine.io instances (on different paths) would result in the closing of websocket connections for all of the instances. This happened because each engine.io instance would register an `upgrade` handler on the server. This handler would check for a matching path and otherwise call `socket.end()` Since multiple upgrade events would be triggered with different paths, the peer handlers would close each other. This patch resolves this behavior in the following way: - When an instance upgrade handler encounters a path which it does not recognize it creates a timeout for `destroyUpgradeTimeout`. - At the end of the timeout, the socket is checked for writable state and bytes written. If there has been not activity and the socket is writable, then it will be ended. This allows for peer socket handlers to keep the socket alive by sending some data over it. This also mimics the core node behavior of closing sockets on upgrade when no handler is specified. We consider not handling an upgrade request similar to no handler. However, we cannot immediately end the socket for the reasons noted above. fixes #143