title: Azure Redis SSL Cluster + Lettuce Java (EDIT: lettuce version < 4.2)
body: <p>I need to use Azure Redis Cluster, with password, with SSL, with pipelining support.</p>
  
  <p>I was using Jedis until now but it lacks support for cluster+ssl+password+pipelining combo.</p>
  
  <p>I tried lettuce (<a href="https://github.com/mp911de/lettuce/releases/tag/4.1.2.Final" rel="nofollow">https://github.com/mp911de/lettuce/releases/tag/4.1.2.Final</a>) and currently hit a connection issue I am not able to solve on my own.</p>
  
  <p>Connecting to an Azure Redis Cluster (2 * P4) works without SSL but not with.
  Also I can connect to a single node with SSL but without cluster support.
  Problem is when combining cluster+ssl, the auth call times out (the command is sent over the wire but times out).</p>
  
  <p>The cluster without SSL working code looks like this:</p>
  
  <pre><code>RedisURI redisURI = RedisURI.Builder.redis(host, 6379)
    .withPassword(password)
    .build();
  RedisClusterClient client = RedisClusterClient.create(redisURI);
  RedisAdvancedClusterCommands&lt;String, String&gt; connection = client.connect().sync();
  connection.set("a", "1");
  System.out.println(connection.get("a"));
  </code></pre>
  
  <p>Output is <code>1</code></p>
  
  <p>Enabling SSL:</p>
  
  <pre><code>RedisURI redisURI = RedisURI.Builder.redis(host, 6380)
    .withPassword(password)
    .withSsl(true)
    .build();
  RedisClusterClient client = RedisClusterClient.create(redisURI);
  RedisAdvancedClusterCommands&lt;String, String&gt; connection = client.connect().sync();
  connection.set("a", "1");
  System.out.println(connection.get("a"));
  </code></pre>
  
  <p>It hangs during 1 minute and log4j logs looks like this:</p>
  
  <pre><code>2016-05-26 14:25:17,110 | TRACE | lettuce-nioEventLoop-3-1 | CommandEncoder | [/{CLIENT} -&gt; {HOST}/{IP}:6380] Sent: *2
  $4
  AUTH
  $44
  {PASSWORD}
  2016-05-26 14:26:17,134 | WARN  | main | ClusterTopologyRefresh | Cannot connect to RedisURI [host='***', port=6380]
  com.lambdaworks.redis.RedisCommandTimeoutException: Command timed out
      at com.lambdaworks.redis.LettuceFutures.await(LettuceFutures.java:95)
      at com.lambdaworks.redis.LettuceFutures.awaitOrCancel(LettuceFutures.java:74)
      at com.lambdaworks.redis.AbstractRedisAsyncCommands.auth(AbstractRedisAsyncCommands.java:64)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connectToNode(RedisClusterClient.java:342)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connectToNode(RedisClusterClient.java:301)
      at com.lambdaworks.redis.cluster.ClusterTopologyRefresh.getConnections(ClusterTopologyRefresh.java:240)
      at com.lambdaworks.redis.cluster.ClusterTopologyRefresh.loadViews(ClusterTopologyRefresh.java:132)
      at com.lambdaworks.redis.cluster.RedisClusterClient.loadPartitions(RedisClusterClient.java:468)
      at com.lambdaworks.redis.cluster.RedisClusterClient.initializePartitions(RedisClusterClient.java:445)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterImpl(RedisClusterClient.java:359)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connect(RedisClusterClient.java:244)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connect(RedisClusterClient.java:231)
      at com.ubikod.ermin.reach.tools.Test.main(Test.java:20)
  Exception in thread "main" com.lambdaworks.redis.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host='***', port=6380]]
      at com.lambdaworks.redis.cluster.RedisClusterClient.loadPartitions(RedisClusterClient.java:471)
      at com.lambdaworks.redis.cluster.RedisClusterClient.initializePartitions(RedisClusterClient.java:445)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterImpl(RedisClusterClient.java:359)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connect(RedisClusterClient.java:244)
      at com.lambdaworks.redis.cluster.RedisClusterClient.connect(RedisClusterClient.java:231)
      at com.ubikod.ermin.reach.tools.Test.main(Test.java:20)
  </code></pre>
  
  <p>Keeping SSL and disabling cluster works:</p>
  
  <pre><code>RedisURI redisURI = RedisURI.Builder.redis(host, 6380)
    .withPassword(password)
    .withSsl(true)
    .build();
  RedisClient client = RedisClient.create(redisURI);
  RedisCommands&lt;String, String&gt; connection = client.connect().sync();
  connection.set("a", "1");
  System.out.println(connection.get("a"));
  </code></pre>
  
  <p>So that's not just an SSL issue, its a SSL + cluster combo issue.
  I tried to use <code>withStartTls</code>, disabling peer verification, raising the timeout, any combination of those without luck.</p>
  
  <p>Any idea if it's a library bug or an Azure Redis bug?</p>