diff --git a/lib/Connection.js b/lib/Connection.js index 0596496..478b88d 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -114,6 +114,7 @@ Connection.prototype.connect = function() { socket.once('close', function(had_err) { clearTimeout(self._tmrConn); clearTimeout(self._tmrKeepalive); + self.state = 'disconnected'; self.debug && self.debug('[connection] Closed'); self.emit('close', had_err); }); @@ -121,6 +122,7 @@ Connection.prototype.connect = function() { socket.once('end', function() { clearTimeout(self._tmrConn); clearTimeout(self._tmrKeepalive); + self.state = 'disconnected'; self.debug && self.debug('[connection] Ended'); self.emit('end'); });