Skip to content

Commit

Permalink
Reset retries connect and emit error when silent mode
Browse files Browse the repository at this point in the history
I added the 'connect' event listener to socket to reset the connection
retries counter and 'error' emit to the transport when the maximum
connect retries is reached and the transport is 'silent' mode
  • Loading branch information
ifraixedes committed Nov 13, 2013
1 parent 78dad5b commit 1cd910c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/winston-logstash.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Logstash.prototype.connect = function () {
}
});

this.socket.on('connect', function () {
self.retries = 0;
});

this.socket.on('close', function (had_error) {
self.connected = false;

Expand All @@ -128,6 +132,7 @@ Logstash.prototype.connect = function () {
} else {
self.log_queue = [];
self.silent = true;
self.emit('error', new Error('Max retries reached, transport in silent mode, OFFLINE'));
}
});

Expand Down

0 comments on commit 1cd910c

Please sign in to comment.