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

Node 18 will close proxied websocket connections after ~60 seconds #1664

Open
reey opened this issue Apr 5, 2024 · 0 comments
Open

Node 18 will close proxied websocket connections after ~60 seconds #1664

reey opened this issue Apr 5, 2024 · 0 comments

Comments

@reey
Copy link

reey commented Apr 5, 2024

With Nodejs 18 another set of http timeouts have been introduced:

  • headersTimeout
  • requestTimeout

see: https://nodejs.org/en/blog/release/v18.0.0/#http-timeouts

These timeouts cause that established websocket connections are closed after roughly 60 seconds.
if you inspect the websocket connection via Wireshark, you see that nodejs just sends:

HTTP/1.1 408 Request Timeout
Connection: close

Through the websocket connection after the timeout.

The simplest workaround to prevent this, is to set both timeouts to zero:

const app = express();
[...]
const server = app.listen(process.env.SERVER_PORT);

// disable timeouts as otherwise websocket connections are closed after ~60-90 seconds
server.headersTimeout = 0;
server.requestTimeout = 0;

Other libs actually implemented some handling for these cases: e.g. vercel/next.js@486b362

It would be nice if this could be somehow addressed as part of this lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant