From 597bed62298e721f864b95cceeeb38e61016eae7 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Dec 2016 17:47:15 +0100 Subject: [PATCH] Rework connect_timeout --- README.md | 2 +- index.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c3fc78c57..55e2ee6169 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ __Tip:__ If the Redis server runs on the same machine as the client consider usi | socket_keepalive | true | If set to `true`, the keep-alive functionality is enabled on the underlying socket. | | no_ready_check | false | When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server will not respond to any commands. To work around this, `node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event. Setting `no_ready_check` to `true` will inhibit this check. | | enable_offline_queue | true | By default, if there is no active connection to the Redis server, commands are added to a queue and are executed once the connection has been established. Setting `enable_offline_queue` to `false` will disable this feature and the callback will be executed immediately with an error, or an error will be emitted if no callback is specified. | -| connect_timeout | 3600000 | __Deprecated__ _Please use `retry_strategy` instead._ Setting `connect_timeout` limits the total time for the client to connect and reconnect. The value is provided in milliseconds and is counted from the moment a new client is created or from the time the connection is lost. The last retry is going to happen exactly at the timeout time. Default is to try connecting until the default system socket timeout has been exceeded and to try reconnecting until 1h has elapsed. | +| connect_timeout | 60000 | Setting `connect_timeout` limits the total time for the client to connect the very first time. The value is provided in milliseconds and is counted from the moment a new client is created. Default is to try connecting until the default system socket timeout has been exceeded and to try reconnecting until 1 minute has elapsed. | | retry_unfulfilled_commands | false | If set to `true`, all commands that were unfulfilled while the connection is lost will be retried after the connection has been reestablished. Use this with caution if you use state altering commands (e.g. `incr`). This is especially useful if you use blocking commands. | | password | null | If set, client will run Redis auth command on connect. Alias `auth_pass` __Note__ `node_redis` < 2.5 must use `auth_pass` | | db | null | If set, client will run Redis `select` command on connect. | diff --git a/index.js b/index.js index 83014be58d..e1416123b5 100644 --- a/index.js +++ b/index.js @@ -92,9 +92,8 @@ function RedisClient (options, stream) { 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.pipeline_queue = new Queue(); // Holds all pipelined commands - // ATTENTION: connect_timeout should change in v.3.0 so it does not count towards ending reconnection attempts after x seconds - // This should be done by the retry_strategy. Instead it should only be the timeout for connecting to redis - this.connect_timeout = +options.connect_timeout || 3600000; // 60 * 60 * 1000 ms + // Only used as timeout until redis has to be connected to redis until throwing an connection error + this.connect_timeout = +options.connect_timeout || 60000; // 60 * 1000 ms this.enable_offline_queue = options.enable_offline_queue === false ? false : true; this.initialize_retry_vars(); this.pub_sub_mode = 0;