From f2ee8dbc9ebe9690061dc93357ede0d85364fa39 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 10 Sep 2015 17:59:25 +0200 Subject: [PATCH] Add a connection timeout of 24h as new default for maximum reconnecting --- README.md | 5 +++-- index.js | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4e51156cae..51523b21f5 100644 --- a/README.md +++ b/README.md @@ -194,8 +194,9 @@ with an error, or an error will be thrown if no callback is specified. * `retry_max_delay`: defaults to `null`. By default every time the client tries to connect and fails time before reconnection (delay) almost doubles. This delay normally grows infinitely, but setting `retry_max_delay` limits delay to maximum value, provided in milliseconds. -* `connect_timeout` defaults to `false`. By default client will try reconnecting until connected. Setting `connect_timeout` -limits total time for client to reconnect. Value is provided in milliseconds and is counted once the disconnect occured. +* `connect_timeout` defaults to `86400000`. Setting `connect_timeout` limits total time for client to reconnect. +Value is provided in milliseconds and is counted once the disconnect occured. The last retry is going to happen once after the connect_timeout value is exceeded. +That way the default is to try reconnecting until at least 24h passed. * `max_attempts` defaults to `null`. By default client will try reconnecting until connected. Setting `max_attempts` limits total amount of reconnects. * `auth_pass` defaults to `null`. By default client will try connecting without auth. If set, client will run redis auth command on connect. diff --git a/index.js b/index.js index cf6a862a21..7b4170ad79 100644 --- a/index.js +++ b/index.js @@ -58,9 +58,7 @@ function RedisClient(stream, options) { 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.commands_sent = 0; - if (options.connect_timeout && options.connect_timeout > 0) { - this.connect_timeout = +options.connect_timeout; - } + this.connect_timeout = +options.connect_timeout || 86400000; // 24 * 60 * 60 * 1000 ms this.enable_offline_queue = true; if (this.options.enable_offline_queue === false) { this.enable_offline_queue = false;