Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -1998,9 +1998,13 @@ value only affects new connections to the server, not any existing connections.

<!-- YAML
added: v8.0.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/62782
description: the default value for `http.Server.keepAliveTimeout` is changed from 5 to 65 seconds.
-->

* Type: {number} Timeout in milliseconds. **Default:** `5000` (5 seconds).
* Type: {number} Timeout in milliseconds. **Default:** `65000` (65 seconds).

The number of milliseconds of inactivity a server needs to wait for additional
incoming data, after it has finished writing the last response, before a socket
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ function storeHTTPOptions(options) {
validateInteger(keepAliveTimeout, 'keepAliveTimeout', 0);
this.keepAliveTimeout = keepAliveTimeout;
} else {
this.keepAliveTimeout = 5_000; // 5 seconds;
this.keepAliveTimeout = 65_000; // 65 seconds;
}

const keepAliveTimeoutBuffer = options.keepAliveTimeoutBuffer;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http-keep-alive-max-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const bodySent = 'This is my request';
function assertResponse(headers, body, expectClosed) {
if (expectClosed) {
assert.match(headers, /Connection: close\r\n/m);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5\r\n/m), -1);
assert.strictEqual(headers.search(/Keep-Alive: timeout=65\r\n/m), -1);
assert.match(body, /Hello World!/m);
} else {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
assert.match(headers, /Keep-Alive: timeout=65, max=3\r\n/m);
assert.match(body, /Hello World!/m);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-keep-alive-pipeline-max-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const bodySent = 'This is my request';
function assertResponse(headers, body, expectClosed) {
if (expectClosed) {
assert.match(headers, /Connection: close\r\n/m);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5, max=3\r\n/m), -1);
assert.strictEqual(headers.search(/Keep-Alive: timeout=65, max=3\r\n/m), -1);
assert.match(body, /Hello World!/m);
} else {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
assert.match(headers, /Keep-Alive: timeout=65, max=3\r\n/m);
assert.match(body, /Hello World!/m);
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ server.listen(0, common.mustCall((res) => {

assert.match(responseParts[6], /HTTP\/1\.1 503 Service Unavailable/m);
assert.match(responseParts[6], /Connection: close\r\n/m);
assert.strictEqual(responseParts[6].search(/Keep-Alive: timeout=5\r\n/m), -1);
assert.strictEqual(responseParts[6].search(/Keep-Alive: timeout=65\r\n/m), -1);
assert.strictEqual(responseParts[7].search(/Hello World!/m), -1);

socket.end();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-server-keep-alive-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bodySent = 'This is my request';

function assertResponse(headers, body, expectClosed) {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5\r\n/m);
assert.match(headers, /Keep-Alive: timeout=65\r\n/m);
assert.match(body, /Hello World!/m);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const bodySent = 'This is my request';

function assertResponse(headers, body, expectClosed) {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5\r\n/m);
assert.match(headers, /Keep-Alive: timeout=65\r\n/m);
assert.match(body, /Hello World!/m);
}

Expand Down
Loading