Skip to content

Commit

Permalink
Resolve intermittent premature connection closed (#19808)
Browse files Browse the repository at this point in the history
Node 8 changed the keepAlive to default to 5 seconds from 5 minutes. This reverts that behavior.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
tylersmalley committed Jun 11, 2018
1 parent 896334e commit c360fca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/server/http/setup_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export function setupConnection(server, config) {

// not using https? well that's easy!
if (!useSsl) {
server.connection(connectionOptions);
const connection = server.connection(connectionOptions);

// revert to previous 5m keepalive timeout in Node < 8
connection.listener.keepAliveTimeout = 120e3;

return;
}

Expand All @@ -47,6 +51,9 @@ export function setupConnection(server, config) {
}
});

// revert to previous 5m keepalive timeout in Node < 8
connection.listener.keepAliveTimeout = 120e3;

const badRequestResponse = new Buffer('HTTP/1.1 400 Bad Request\r\n\r\n', 'ascii');
connection.listener.on('clientError', (err, socket) => {
if (socket.writable) {
Expand Down

0 comments on commit c360fca

Please sign in to comment.