Skip to content

Commit 9f75269

Browse files
pimterrypras529
andauthored
http: increase keepAliveTimeout default to 65 seconds
Co-authored-by: Prashant Bansal <[email protected]> Signed-off-by: Tim Perry <[email protected]> PR-URL: #62782 Reviewed-By: Xuguang Mei <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Gürgün Dayıoğlu <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
1 parent adef648 commit 9f75269

6 files changed

Lines changed: 13 additions & 9 deletions

doc/api/http.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,9 +1999,13 @@ value only affects new connections to the server, not any existing connections.
19991999

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

2004-
* Type: {number} Timeout in milliseconds. **Default:** `5000` (5 seconds).
2008+
* Type: {number} Timeout in milliseconds. **Default:** `65000` (65 seconds).
20052009

20062010
The number of milliseconds of inactivity a server needs to wait for additional
20072011
incoming data, after it has finished writing the last response, before a socket

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ function storeHTTPOptions(options) {
499499
validateInteger(keepAliveTimeout, 'keepAliveTimeout', 0);
500500
this.keepAliveTimeout = keepAliveTimeout;
501501
} else {
502-
this.keepAliveTimeout = 5_000; // 5 seconds;
502+
this.keepAliveTimeout = 65_000; // 65 seconds;
503503
}
504504

505505
const keepAliveTimeoutBuffer = options.keepAliveTimeoutBuffer;

test/parallel/test-http-keep-alive-max-requests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ const bodySent = 'This is my request';
1010
function assertResponse(headers, body, expectClosed) {
1111
if (expectClosed) {
1212
assert.match(headers, /Connection: close\r\n/m);
13-
assert.strictEqual(headers.search(/Keep-Alive: timeout=5\r\n/m), -1);
13+
assert.strictEqual(headers.search(/Keep-Alive: timeout=65\r\n/m), -1);
1414
assert.match(body, /Hello World!/m);
1515
} else {
1616
assert.match(headers, /Connection: keep-alive\r\n/m);
17-
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
17+
assert.match(headers, /Keep-Alive: timeout=65, max=3\r\n/m);
1818
assert.match(body, /Hello World!/m);
1919
}
2020
}

test/parallel/test-http-keep-alive-pipeline-max-requests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ const bodySent = 'This is my request';
1010
function assertResponse(headers, body, expectClosed) {
1111
if (expectClosed) {
1212
assert.match(headers, /Connection: close\r\n/m);
13-
assert.strictEqual(headers.search(/Keep-Alive: timeout=5, max=3\r\n/m), -1);
13+
assert.strictEqual(headers.search(/Keep-Alive: timeout=65, max=3\r\n/m), -1);
1414
assert.match(body, /Hello World!/m);
1515
} else {
1616
assert.match(headers, /Connection: keep-alive\r\n/m);
17-
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
17+
assert.match(headers, /Keep-Alive: timeout=65, max=3\r\n/m);
1818
assert.match(body, /Hello World!/m);
1919
}
2020
}
@@ -76,7 +76,7 @@ server.listen(0, common.mustCall((res) => {
7676

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

8282
socket.end();

test/parallel/test-http-server-keep-alive-defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const bodySent = 'This is my request';
99

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

test/parallel/test-http-server-keep-alive-max-requests-null.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const bodySent = 'This is my request';
99

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

0 commit comments

Comments
 (0)