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 <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2018-06-11 14:51:11 -07:00 committed by Tyler Smalley
parent dd9e095f19
commit 83dd263048

View file

@ -47,7 +47,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;
}
@ -66,6 +70,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) {