Skip to content

Commit c360fca

Browse files
authored
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 896334e commit c360fca

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
@@ -28,7 +28,11 @@ export function setupConnection(server, config) {
2828

2929
// not using https? well that's easy!
3030
if (!useSsl) {
31-
server.connection(connectionOptions);
31+
const connection = server.connection(connectionOptions);
32+
33+
// revert to previous 5m keepalive timeout in Node < 8
34+
connection.listener.keepAliveTimeout = 120e3;
35+
3236
return;
3337
}
3438

@@ -47,6 +51,9 @@ export function setupConnection(server, config) {
4751
}
4852
});
4953

54+
// revert to previous 5m keepalive timeout in Node < 8
55+
connection.listener.keepAliveTimeout = 120e3;
56+
5057
const badRequestResponse = new Buffer('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii');
5158
connection.listener.on('clientError', (err, socket) => {
5259
if (socket.writable) {

0 commit comments

Comments
 (0)