1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Use connect_timeout also as the socket_timeout if explicitly provided

Fixes #587
Fixes #393
Closes #652
Closes #394
This commit is contained in:
Ruben Bridgewater
2015-10-29 13:49:01 +01:00
parent afc4989495
commit dc6fc9c113
4 changed files with 55 additions and 4 deletions

View File

@@ -85,7 +85,7 @@ function RedisClient(stream, options) {
this.max_attempts = options.max_attempts | 0;
this.command_queue = new Queue(); // Holds sent commands to de-pipeline them
this.offline_queue = new Queue(); // Holds commands issued but not able to be sent
this.connect_timeout = +options.connect_timeout || 86400000; // 24 * 60 * 60 * 1000 ms
this.connect_timeout = +options.connect_timeout || 3600000; // 60 * 60 * 1000 ms
this.enable_offline_queue = options.enable_offline_queue === false ? false : true;
this.retry_max_delay = +options.retry_max_delay || null;
this.initialize_retry_vars();
@@ -108,6 +108,13 @@ util.inherits(RedisClient, events.EventEmitter);
RedisClient.prototype.install_stream_listeners = function() {
var self = this;
if (this.options.connect_timeout) {
this.stream.setTimeout(this.connect_timeout, function () {
self.retry_totaltime = self.connect_timeout;
self.connection_gone('timeout');
});
}
this.stream.on('connect', function () {
self.on_connect();
});