-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
I use the max_attempts option in pretty much the most straight-forward way possible:
process.on('uncaughtException', function (err) {
console.log(err.toString());
});
var client = redis.createClient({
host: '127.0.0.1'.
port: 6379,
max_attempts: 1
});
However, if no redis server is running and the client can't connect, it keeps on trying, instead of giving up after the specified number of attempts:
$ node app
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:[object Object] failed - connect ECONNREFUSED
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
…
It might be worth noting that the client was never connected to the server in the first place in this scenario. This is the first connection it attempts to establish.
I'm also somewhat confused by the doubled error messages, once for 127.0.0.1:[object Object]
and once for 127.0.0.1:6379
that seem to be thrown at about the same time, for each failed connection attempt.