From 3a0b9fce221b6a67f7c395cd21a0a6082caefacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Brostr=C3=B6m?= Date: Tue, 21 Nov 2017 16:33:25 +0100 Subject: [PATCH] Add setKeepAlive for net.socket * Prevent `Error: read ECONNRESET` when using net.socket by using setKeepAlive when connecting. * Use an `initialDelay` of 60 seconds. Net -> socket.setKeepAlive: https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay Closes #38, #41 --- lib/winston-logstash.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/winston-logstash.js b/lib/winston-logstash.js index 8d02603..9f88f16 100644 --- a/lib/winston-logstash.js +++ b/lib/winston-logstash.js @@ -199,6 +199,7 @@ Logstash.prototype.connect = function () { this.socket.connect(self.port, self.host, function () { self.announce(); self.connecting = false; + self.socket.setKeepAlive(true, 60 * 1000); }); } @@ -243,4 +244,4 @@ Logstash.prototype.sendLog = function (message, callback) { Logstash.prototype.getQueueLength = function () { return this.log_queue.length; -}; \ No newline at end of file +};