Skip to content

redis.createClient: max_attempts seems to be ignored #566

@ClaudioAlbertin

Description

@ClaudioAlbertin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions