title: JedisCluster : redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster
body: <p>I was trying to connect to JedisCluster  (ElastiCache Redis) from java. But I was getting JedisConnectionException with No reachable node in the cluster.</p>
  
  <p>Here was my code to connect to JedisCluster</p>
  
  <pre><code>public static void main(String[] args) throws IOException{
          final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
          poolConfig.setMaxWaitMillis(2000);
          poolConfig.setMaxTotal(300);
          Set&lt;HostAndPort&gt; jedisClusterNode = new HashSet&lt;HostAndPort&gt;();
          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();
          }
      }
  </code></pre>
  
  <p>The exception I got after running this</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I have checked </p>
  
  <pre><code>telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 6379
  </code></pre>
  
  <p>as mentioned in <a href="https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/GettingStarted.ConnectToCacheNode.html" rel="noreferrer">AWS Doc</a> I got the reply as Connected. </p>
  
  <p>What is the issue here and why I am not able to connect to the JedisCluster using java?</p>
  
  <p>Note : </p>
  
  <p>I am using jedis version 2.9.0</p>
  
  <p>Update:</p>
  
  <p>In AWS <strong>Encryption in-transit and Encryption at-rest are activated</strong></p>
  
  <p>So</p>
  
  <pre><code>Jedis jedis = null;
          try{
              jedis = new Jedis(URI.create("rediss://mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com:6379"));
              System.out.println(jedis.ping());
              System.out.println("XXXXX: "+jedis.get("c"));
          }
          catch(Exception exception){
              exception.printStackTrace();
          }
          finally{
              jedis.close();
          }
  </code></pre>
  
  <p>works fine. But not the jedis cluster.</p>