Configure keepAliveTimeout/timeout on HTTP server (Node 8+) to prevent increased delay after idling #165

Closed
opened 2025-08-09 17:15:15 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @aloker on 2/18/2018

See https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout

As described in https://github.com/aspnet/JavaScriptServices/issues/1368, starting from Node v8, the server will disconnect the socket after 5 seconds of idling. Re-establishing the socket seems to take something in the order of tenths of seconds, making SPA prerendering requests with more than 5 seconds in between taking considerably longer than necessary (e.g. >1 second).

I suggest setting the keepAliveTimeout to a higher value, or to 0 or to make it configurable.

Update: also, the timeout property (https://nodejs.org/api/http.html#http_server_timeout) should be configurable. By default, the server-socket will timeout after 2 minutes, even if the keepAliveTimeout is set to 0.

*Originally created by @aloker on 2/18/2018* See https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_server_keepalivetimeout As described in https://github.com/aspnet/JavaScriptServices/issues/1368, starting from Node v8, the server will disconnect the socket after 5 seconds of idling. Re-establishing the socket seems to take something in the order of tenths of seconds, making SPA prerendering requests with more than 5 seconds in between taking considerably longer than necessary (e.g. >1 second). I suggest setting the keepAliveTimeout to a higher value, or to 0 or to make it configurable. Update: also, the `timeout` property (https://nodejs.org/api/http.html#http_server_timeout) should be configurable. By default, the server-socket will timeout after 2 minutes, even if the keepAliveTimeout is set to 0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#165
No description provided.