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

Cluster: automatic nodes discovery not working with remote host #156

Closed
Adrien-P opened this issue Sep 24, 2015 · 5 comments
Closed

Cluster: automatic nodes discovery not working with remote host #156

Adrien-P opened this issue Sep 24, 2015 · 5 comments
Labels

Comments

@Adrien-P
Copy link

My current setup is the following:
I have a machine on IP 10.0.0.6 which hosts a redis cluster with 3 masters (ports 7000, 7001 and 7002) and 3 slaves (ports 7003, 7004, 7005).
The client machine is on IP 10.0.0.7 and I pass the configuration:

new Redis.Cluster([{
            port: 7000,
            host: "10.0.0.6"
        }], {db: 0});

the issue is that my redis node on port 7000 keeps receiving an unlimited amount of "info" requests but never receives the actual requests made within the client code. Looking at the code I think I found the source of the issue:
In the method Cluster.prototype.getInfoFromNode there is a command redis.cluster('slots',... and the results of this command are like this:

[ [ 0, 5460, [ '127.0.0.1', 7000 ], [ '127.0.0.1', 7003 ] ],
  [ 10923, 16383, [ '127.0.0.1', 7002 ], [ '127.0.0.1', 7005 ] ],
  [ 5461, 10922, [ '127.0.0.1', 7001 ], [ '127.0.0.1', 7004 ] ] ]

What happens is that the redis node on 10.0.0.6:7000 replies with the list of nodes that are part of the cluster but it reference them with their localhost address (127.0.0.1 instead of 10.0.0.6). Thus, ioredis tries to connect to theses nodes on 127.0.0.1 and keeps getting ECONNREFUSED (because the client machine does not host any redis instance).

Note: I tried to pass all the nodes to the Redis.Cluster constructor and I experienced the same "info" loop issue

@AVVS
Copy link
Collaborator

AVVS commented Sep 24, 2015

Thats likely a problem with setting up your cluster

On 24 Sep 2015, at 14:24, Adrien-P [email protected] wrote:

My current setup is the following:

I have a machine on IP 10.0.0.6 which hosts a redis cluster with 3 masters (ports 7000, 7001 and 7002) and 3 slaves (ports 7003, 7004, 7005).

The client machine is on IP 10.0.0.7 and I pass the configuration:

new Redis.Cluster([{
port: 7000,
host: "10.0.0.6"
}], {db: 0});
the issue is that my redis node on port 7000 keeps receiving an unlimited amount of "info" requests but never receives the actual requests within the client code. Looking at the code I think I found the source of the issue:

In the method Cluster.prototype.getInfoFromNode there is a command redis.cluster('slots',... and the results of this command are like this:

[ [ 0, 5460, [ '127.0.0.1', 7000 ], [ '127.0.0.1', 7003 ] ],
[ 10923, 16383, [ '127.0.0.1', 7002 ], [ '127.0.0.1', 7005 ] ],
[ 5461, 10922, [ '127.0.0.1', 7001 ], [ '127.0.0.1', 7004 ] ] ]
What happens is that the redis node on 10.0.0.6:7000 replies with the list of nodes but with the localhost address (not the 10.0.0.6). Thus, ioredis tries to connect to theses nodes on 127.0.0.1 and keeps getting ECONNREFUSED (because the client machine does not host any redis instance).

Note: I tried to pass all the nodes to the Redis.Cluster constructor and I experienced the same "info" loop issue


Reply to this email directly or view it on GitHub.

@Adrien-P
Copy link
Author

If anyone has managed to setup ioredis with a cluster on another machine, I'd be happy to know your configuration

@luin
Copy link
Collaborator

luin commented Sep 24, 2015

Hi @Adrien-P
Thanks for using ioredis. The redis servers running on the other machines returns 127.0.0.1 is because you bound the redis to the wrong network interface (in this case, bind 127.0.0.1).

You can refer to this issue for more details: https://github.com/antirez/redis/pull/1590/files.

@luin luin added the question label Sep 24, 2015
@Adrien-P
Copy link
Author

Hi @luin

thanks a lot for your answer. bind is definitely the option I was looking for.
For those interested I added this line to my redis.conf files for each node:
bind 10.0.0.6 127.0.0.1

now it works well.
On a side note, we just moved to ioredis from node_redis mostly because of the support of Redis Cluster. The migration has been very easy

@luin
Copy link
Collaborator

luin commented Sep 24, 2015

😆

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

3 participants