Skip to content

Commit a110f7e

Browse files
pimterrypras529
andcommitted
http: increase keepAliveTimeout default to 65 seconds
Co-authored-by: Prashant Bansal <prashantbansal529@gmail.com> Signed-off-by: Tim Perry <pimterry@gmail.com>
1 parent 2071c44 commit a110f7e

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
@@ -1998,9 +1998,13 @@ value only affects new connections to the server, not any existing connections.
19981998

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

2003-
* Type: {number} Timeout in milliseconds. **Default:** `5000` (5 seconds).
2007+
* Type: {number} Timeout in milliseconds. **Default:** `65000` (65 seconds).
20042008

20052009
The number of milliseconds of inactivity a server needs to wait for additional
20062010
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)