-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
http server upgrade event #23857
Comments
Hi, @jordbaer. I think that is expected. And Did you expect |
I don't think that is expected. The http code doesn't know what the upgraded protocol needs to do. Maybe the protocol wants to send a message to the socket when a timeout happens. Doesn't work, because the http code destroys the socket before the upgraded protocol event gets the "timeout" event. Yes, I expect socket.setTimeout(0) and the removal of the http timeout listener to be done before the "upgrade" event is emitted. Because all other http listeners to all other events are removed too. And because the http server is no longer in charge of the socket. |
@nodejs/http |
I'm not sure. I agree that we should remove the default listener of the The user can set a custom timeout: server.on('connection', function(socket) {
socket.setTimeout(1000);
}); and in this case it might surprising to see that the idle timeout is gone when the |
I think it's better to override it in user code after the |
Remove the default listener of the `'timeout'` event from the socket before emitting the `'connect'` or `'upgrade'` event. Fixes: nodejs#23857
http server upgrade event:
When the 'upgrade' event is emitted, the http server doesn't unregister the 'timeout' handler (function socketOnTimeout).
If a timeout event occurs later, the http server code will destroy the socket.
workaround:
server.on("upgrade", (req,socket,head) => {
socket.removeAllListeners("timeout");
socket.setTimeout(0);
...
});
The text was updated successfully, but these errors were encountered: