Is there no .isConencted() when using JedisCluster? #3298
Replies: 8 comments 1 reply
-
Using this code, I am trying to connect, but the first exception thrown is "Failed to connect to any host resolved for DNS name" at my System.out.println where i print the key and then pool.isClosed() etc.
This cant be right? |
Beta Was this translation helpful? Give feedback.
-
Your Java application can't connect to at least one of the cluster nodes, probably due to firewall or something else. Split your
Lastly,
|
Beta Was this translation helpful? Give feedback.
-
Oh. I think I can see the issue. However it does not make any sense to me: I've split the lines according to you. Key: 192.168.1.111:7002 I am using a IPSec Tunnel between the Client and the Redis-Cluster. Now, since this is a Redis-Cluster, I can imagine that if it tries to e.g. read, the Cluster says "nope, I dont have that key/set available, please go to instance Y". Does REDIS upon connection use any sort of hostnames? The "DNS" part is still unclear to me. |
Beta Was this translation helpful? Give feedback.
-
The host you provide goes though JVM's DNS. You don't have to be concerned when it's an IP because the JavaDoc says: "If a literal IP address is supplied, only the validity of the address format is checked."
No.
It doesn't matter whether you all provide all hosts or not. Jedis uses the hosts reported by Redis server, for internal cluster management, not provided by you. The hosts provided are used as the first contact point. When asking for help, it's better to provide a longer stacktrace instead of only the message. I believe your exception contains another suppressed exception as well. Whether the exception contains another suppressed one or not makes a huge difference while going deep into the issue. Because when not given, our first assumption would be that there's no suppressed one. Moreover, your actual cluster node addresses are not the same as the ones you're providing is another huge information that was missing. Please try to provide as much information as you can as early as possible, of course in a sanely concise way. Please don't take this comment in a negative way. I appreciate you created a discussion instead of an issue which most users don't follow even after requests. And of course thank you for using Jedis. Now, coming to the solution, as your actual cluster node addresses different from the addresses your java application (Jedis) can communicate with, provide an implementation of |
Beta Was this translation helpful? Give feedback.
-
Sorry for not being more clear in my question. I wasn't aware that Redis responds with IP-Addresses to tell where the requested data can be fetched. For me it seems like its just an Interface with "no" implementations? In the means of its nowhere used inside the library? I'd really like to use it. Am I missing documentation? |
Beta Was this translation helpful? Give feedback.
-
There are no implementations of Any form of contribution is always welcome, even documentation! I just realized there are no JedisCluster constructor taking a HostAndPortMapper directly. You may choose any constructor taking |
Beta Was this translation helpful? Give feedback.
-
Jep, this worked out. Just for anyone else who is seeing this: Incase of my 2 Redis-Servers with multiple Instances, this was enough:
You can certainly create a Hashmap that maps the IPs 192.168.1.110 to 192.168.100.110 and just look it up inside that function, but since i only have 2 of them, I just used an If-Statement. I supplied it to the JedisCluster Constructor like this:
|
Beta Was this translation helpful? Give feedback.
-
I am getting no connection currently in one of my projects, therefore I wanted to see if the connection to the cluster is actuall "up".
I installed redis-cli on the clients where my project runs on and made sure that my cluster works aswell as the connection to it. And well, it does.
However, seemingly, any call to modify sets (in my case) does result in an error (No more cluster attempts left -> Failed to connect to any host for DNS name -> ConnectionTimeout).
First of all, I am not using any DNS names/hostnames, but only the raw IPs and Ports.
I have seen #2225, but I dont get any exception.
Also, I just noticed the getConnectionFromSlot() function. Do i have to iterate over all 16k Slots to check if all connections are up / if I can make requests?
Or should I use the getClusterNodes() function to retrieve a Map? Also, what is the String Key in the map?
Beta Was this translation helpful? Give feedback.
All reactions