Skip to content

Commit

Permalink
Add setKeepAlive for net.socket
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Andreas Broström committed Nov 21, 2017
1 parent 26323b6 commit 3a0b9fc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/winston-logstash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -243,4 +244,4 @@ Logstash.prototype.sendLog = function (message, callback) {

Logstash.prototype.getQueueLength = function () {
return this.log_queue.length;
};
};

0 comments on commit 3a0b9fc

Please sign in to comment.