You've already forked node-redis
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:
9
index.js
9
index.js
@@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user