Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #14 from inindev/patch-1

Update lib/nssocket.js
  • Loading branch information...
commit 4778e93b380d4b8cad6b03a2784375b29d59a6f0 2 parents d0c605d + f4955f5
@indexzero indexzero authored
Showing with 13 additions and 7 deletions.
  1. +13 −7 lib/nssocket.js
View
20 lib/nssocket.js
@@ -191,16 +191,18 @@ NsSocket.prototype.reconnect = function reconnect() {
return self.emit('error', new Error('Did not reconnect after maximum retries: ' + self.retry.max));
}
- self.retry.waiting = true;
-
// here for debugging reasons
assert.isFalse(self.connected, 'before actually reconnect connected must be false');
assert.isUndefined(self.socket, 'before actually reconnect socket must be destroied');
- self.once('start', function () {
- self.retry.waiting = false;
- self.retry.retries = 0;
- });
+ if (!self.retry.waiting) {
+ self.retry.waiting = true;
+
+ self.once('start', function () {
+ self.retry.waiting = false;
+ self.retry.retries = 0;
+ });
+ }
self.connect.apply(self, self.connectionArgs);
}, this.retry.wait);
@@ -281,6 +283,10 @@ function configureEvents(self) {
self.retry && self.reconnect();
});
+ self.stream.on('error', function (err) {
+ !self.retry && self.emit('error', err || new Error('An Unknown Error occured'));
+ });
+
self.socket.on('error', function (err) {
!self.retry && self.emit('error', err || new Error('An Unknown Error occured'));
});
@@ -289,4 +295,4 @@ function configureEvents(self) {
self.emit('idle');
self.timeout && self.socket.setTimeout(this.timeout);
});
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.