Respond to ETIMEDOUT error with a retry #109

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+10 −1
Split
View
@@ -577,7 +577,16 @@ Client.prototype.connect = function ( retryCount, callback ) { // {{{
}, self.opt.retryDelay );
});
self.conn.addListener("error", function(exception) {
- self.emit("netError", exception);
+ util.log('Connection got "error" event with exception: ' + exception);
+ if (exception.message.match(/ETIMEDOUT/)) {
+ util.log("Responding to ETIMEDOUT socket error by disconnecting, reconnecting");
+ self.disconnect('Disconnecting because of socket ETIMEDOUT');
+ setTimeout( function() {
+ self.connect( retryCount + 1 );
+ }, self.opt.retryDelay );
+ } else {
+ self.emit("netError", exception);
+ }
});
}; // }}}
Client.prototype.disconnect = function ( message, callback ) { // {{{