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;
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:
Through the websocket connection after the timeout.
The simplest workaround to prevent this, is to set both timeouts to zero:
Other libs actually implemented some handling for these cases: e.g. https://github.com/vercel/next.js/commit/486b36237a213ebf4c19a3bd8f296fad5b400a64
It would be nice if this could be somehow addressed as part of this lib.