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

[BUG] Unable to create a Subscriber object to cluster inside a docker container #353

Closed
KonradPR opened this issue Apr 22, 2022 · 2 comments

Comments

@KonradPR
Copy link

Describe the bug
I have a service that needs to access a redis cluster. I started development with placing the service and cluster in the same Docker container and it worked without a problem. Unfortunately when I tried to place both the service and cluster in separate containers the cluster client is unable to create a subscriber. The subscriber() method call on RedisCluster fails with a following stacktrace:

#0 0x00007f7e7e97c672 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007f7e7eaedd4f in sw::redis::throw_error(redisContext const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) [clone .cold] () from /usr/local/lib/libredis++.so.1
#2 0x00007f7e7eafdc4f in sw::redis::Connection::Connector::connect() const () from /usr/local/lib/libredis++.so.1
#3 0x00007f7e7eaff0c4 in sw::redis::Connection::Connection(sw::redis::ConnectionOptions const&) () from /usr/local/lib/libredis++.so.1
#4 0x00007f7e7eb19034 in sw::redis::RedisCluster::subscriber() () from /usr/local/lib/libredis++.so.1
#5 0x0000555eaa058a9a in main (argc=1, argv=0x7fffdf5c40f8) at ../test.cpp:9

To Reproduce
I have provided a minimal example in this repository:
https://github.com/KonradPR/redis-example
It contains a simple docker compose that runs the minimal setup capable of the bug reproduction.

Expected behavior
I expected to create a Subscriber object without a problem.

Environment:

  • OS: [Ubuntu 20.04.4 LTS]
  • Docker version: [20.10.7]
  • Compose version: [1.29.2]
  • hiredis version: [master, commit d7683f35aa66e222aad07caf5b345393d0c1b9f1 ]
  • redis-plus-plus version: [master, commit 463f341]

Additional context
I would be thankful for any sugestions or directions as to what can be the source of the problem.

Best Regards,
Konrad

@KonradPR KonradPR changed the title [BUG] [BUG] Unable to create a Subscriber object to cluster inside a docker container Apr 22, 2022
@sewenew
Copy link
Owner

sewenew commented Apr 23, 2022

I think the problem is that you create the cluster with localhost, i.e. 127.0.0.1:

redis-cli -a pass --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

In this case, nodes in Redis Cluster connects to each other with localhost, and send redirection response to client with localhost. So when client is redirected, it tries to connect to a local address, and it does not exist.

You might need to seek help from a Redis and docker expert on how to create the cluster with IP address other than localhost.

Regards

@sewenew
Copy link
Owner

sewenew commented Apr 29, 2022

Since there's no update. I'll close this issue.

Regards

@sewenew sewenew closed this as completed Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants