Skip to content

Commit

Permalink
Merge pull request #172 from jeffjen/master
Browse files Browse the repository at this point in the history
Fix tls connect event is "secureConnect"
  • Loading branch information
luin committed Oct 11, 2015
2 parents 9178f60 + d953139 commit e8131e7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,14 @@ Redis.prototype.connect = function (callback) {
reject(err);
return;
}
var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect';

_this.stream = stream;
if (typeof _this.options.keepAlive === 'number') {
stream.setKeepAlive(true, _this.options.keepAlive);
}

stream.once('connect', eventHandler.connectHandler(_this));
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
stream.once('error', eventHandler.errorHandler(_this));
stream.once('close', eventHandler.closeHandler(_this));
stream.on('data', eventHandler.dataHandler(_this));
Expand All @@ -272,7 +273,7 @@ Redis.prototype.connect = function (callback) {
stream.setTimeout(0);
stream.destroy();
});
stream.once('connect', function () {
stream.once(CONNECT_EVENT, function () {
stream.setTimeout(0);
});
}
Expand All @@ -282,10 +283,10 @@ Redis.prototype.connect = function (callback) {
resolve();
};
var connectionCloseHandler = function (err) {
_this.removeListener('connect', connectionConnectHandler);
_this.removeListener(CONNECT_EVENT, connectionConnectHandler);
reject(err);
};
_this.once('connect', connectionConnectHandler);
_this.once(CONNECT_EVENT, connectionConnectHandler);
_this.once('close', connectionCloseHandler);
});
}.bind(this)).nodeify(callback);
Expand Down

0 comments on commit e8131e7

Please sign in to comment.