Skip to content

Commit 83dd263

Browse files
tylersmalleyTyler Smalley
authored andcommitted
Resolve intermittent premature connection closed (#19808)
Node 8 changed the keepAlive to default to 5 seconds from 5 minutes. This reverts that behavior. Signed-off-by: Tyler Smalley <[email protected]>
1 parent dd9e095 commit 83dd263

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/server/http/setup_connection.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ export function setupConnection(server, config) {
4747

4848
// not using https? well that's easy!
4949
if (!useSsl) {
50-
server.connection(connectionOptions);
50+
const connection = server.connection(connectionOptions);
51+
52+
// revert to previous 5m keepalive timeout in Node < 8
53+
connection.listener.keepAliveTimeout = 120e3;
54+
5155
return;
5256
}
5357

@@ -66,6 +70,9 @@ export function setupConnection(server, config) {
6670
}
6771
});
6872

73+
// revert to previous 5m keepalive timeout in Node < 8
74+
connection.listener.keepAliveTimeout = 120e3;
75+
6976
const badRequestResponse = new Buffer('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii');
7077
connection.listener.on('clientError', (err, socket) => {
7178
if (socket.writable) {

0 commit comments

Comments
 (0)