JedisCluster : redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster

4,786 views
Skip to first unread message
Message has been deleted

MMA

unread,
Jan 16, 2018, 7:33:12 AM1/16/18
to Jedis

I was trying to connect to JedisCluster (ElastiCache Redis) from java. But I was getting JedisConnectionException with No reachable node in the cluster.

Here was my code to connect to JedisCluster

public static void main(String[] args) throws IOException{
        final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        poolConfig.setMaxWaitMillis(2000);
        poolConfig.setMaxTotal(300);
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com",6379));
        jedisClusterNode.add(new HostAndPort("mycachecluster.eaogs8.0002.usw2.cache.amazonaws.com",6379));
        JedisCluster jedisCluster = new JedisCluster(jedisClusterNode,poolConfig);
        System.out.println("Cluster Size...." + jedisCluster.getClusterNodes().size());
        try{
            jedisCluster.set("foo", "bar");
            jedisCluster.get("foo");
        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally{
            jedisCluster.close();
        }
    }

The exception I got after running this

redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster
    at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnection(JedisSlotBasedConnectionHandler.java:57)
    at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnectionFromSlot(JedisSlotBasedConnectionHandler.java:74)
    at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:116)
    at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:31)
    at redis.clients.jedis.JedisCluster.set(JedisCluster.java:103)

I have checked

telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 6379

as mentioned in AWS Doc I got the reply as Connected.

What is the issue here and why I am not able to connect to the JedisCluster using java?

Note :

I am using jedis version 2.9.0

Allan Wax

unread,
Jan 17, 2018, 4:52:23 PM1/17/18
to Jedis
How did you create the cluster before trying to connect to it?  Just mentioning two machines when you try to open does not create a cluster.
A minimum Redis cluster is 3 masters and 3 slaves and it has to be created before using it.  It's possible to create a cluster with just 3 masters but you have nothing to failover to.

Adolfo Herrera

unread,
Jun 6, 2018, 2:06:57 PM6/6/18
to Jedis
Were you able to find a fix for this issue? I'm having the same problem.

Paul Leddy

unread,
Feb 12, 2019, 7:39:35 AM2/12/19
to Jedis
Did you set a password and use "in-transit" encryption? 

If so, you need the tunnel established on port 6379 before commands will be recognized on the other side.


On Tuesday, January 16, 2018 at 4:33:12 AM UTC-8, MMA wrote:

Paul Leddy

unread,
Feb 12, 2019, 7:39:35 AM2/12/19
to Jedis
Ditto.
Reply all
Reply to author
Forward
0 new messages