Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error events cannot handle the wrong host error #287

Closed
kenticny opened this issue Apr 24, 2016 · 1 comment
Closed

error events cannot handle the wrong host error #287

kenticny opened this issue Apr 24, 2016 · 1 comment
Labels

Comments

@kenticny
Copy link

I try to make the wrong host to connect, and listening the error events, like below:

var Redis = require('ioredis');

var redis = new Redis({
  host: '127.10.0.1', //  wrong host
  port: 6379,
  db: 1
});

redis.on('error', function(err) {

  // it should be timeout or connect error
  // but cannot handle the error
  console.log(err);
});

and I try to make the wrong port, and the event could handle the connect error
[Error: connect ECONNREFUSED 127.0.0.1:16379]

Is there any way to handle the wrong host connect error ?

@luin
Copy link
Collaborator

luin commented Apr 24, 2016

Currently you can use connectTimeout option to specify a timeout for connection, and ioredis will reconnect to the server when reaching timeout.

However no error will be emitted in case of timeout. I'll fix this soon.

@luin luin added the bug label Apr 24, 2016
@luin luin closed this as completed in 25c300e Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants