-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ioredis client should not attempt to connect to IP addresses from cluster configuration #365
Comments
You should bind the redis to the correct interface instead of |
This just forces to use internal IP and doesn't allow to connect to Redis using localhost or public IP address. I think it's better to still bind to 0.0.0.0 but use In both cases it's not possible to connect to Redis using public IP address or use localhost address for inter-node communication. It's not a big deal as it's probably not a good idea to expose Redis to outside world anyway. It's just that the overall concept of using the same IP address for inter-node communication and user client communication looks not perfect. Perhaps it's more of a general problem in Redis. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
# [4.3.0](redis/ioredis@v4.2.3...v4.3.0) (2018-12-09) ### Features * **cluster:** add NAT support ([#758](redis/ioredis#758)) ([3702d67](redis/ioredis@3702d67)), closes [#693](redis/ioredis#693) [#365](redis/ioredis#365)
I configured Redis cluster consisting of 2 nodes running on the same machine:
redis.conf for 1st node:
redis.conf for 2nd node:
redis-cli -p 6379 cluster slots
returns the following result:Now running
DEBUG=ioredis:* node 1
on a different machine whereshows the following:
As it can be seen it's trying to connect to 127.0.0.1 which is wrong as this address is used for inter-node communication and is not necessarily the one that clients use. I can make it work by running this command:
redis-cli -p 6380 cluster meet 10.2.19.39 6379
After that
redis-cli -p 6379 cluster slots
returns the following result:and
DEBUG=ioredis:* node 1
works properly:I've checked the code of ioredis and indeed, it's using
cluster slots
command to get IP address to connect to:I think this is inherently wrong as IP addresses used for inter-node communication do not necessarily coincide with IP addresses used by clients. For example if a client for whatever reason is forced to use public IP address then the only way to make it work is to specify public IP for inter-node communication:
redis-cli -p 6380 cluster meet 52.17.215.146 6379
The text was updated successfully, but these errors were encountered: