使用 CName 从 Java 连接到加密的 ElastiCache Redis
Connection to Encrypted ElastiCache Redis from Java using a CName
我正在使用 spring 数据中的 Lettuce 驱动程序连接到使用传输中加密的 ElastiCache。当我尝试连接到分配给 ElastiCache 集群的 Route53 CName 时。我收到此错误:
Caused by: com.lambdaworks.redis.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host='my.cname.net', port=6379]]
at com.lambdaworks.redis.cluster.RedisClusterClient.loadPartitions(RedisClusterClient.java:507)
at com.lambdaworks.redis.cluster.RedisClusterClient.initializePartitions(RedisClusterClient.java:481)
at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterAsyncImpl(RedisClusterClient.java:335)
at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterAsync(RedisClusterClient.java:273)
at org.springframework.data.redis.connection.lettuce.LettuceClusterConnection.doGetAsyncDedicatedConnection(LettuceClusterConnection.java:1250)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getAsyncDedicatedConnection(LettuceConnection.java:3466)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getDedicatedConnection(LettuceConnection.java:3487)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getConnection(LettuceConnection.java:3460)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.sMembers(LettuceConnection.java:1998)
... 24 common frames omitted
这是我用来连接的代码:
@Bean
public static RedisConnectionFactory connectionFactory() {
Map<String, Object> source = Maps.newHashMap();
source.put("spring.redis.cluster.nodes", "my.cname.net:6379");
RedisClusterConfiguration clusterConfiguration = new RedisClusterConfiguration(new MapPropertySource("RedisClusterConfiguration", source));
clusterConfiguration.setMaxRedirects(10);
LettuceConnectionFactory factory = new LettuceConnectionFactory(clusterConfiguration);
factory.setValidateConnection(false);
factory.setUseSsl(true);
return factory;
}
现在,当我将 Cname 替换为附加到 ElastiCache 集群的实际网络名称时,程序可以正常工作。有谁知道为什么程序只在使用 Cname 时失败?
我们在 .NET 客户端上遇到了非常相似的问题。我认为问题是因为 Redis 端点用于 amazonaws.com 域的证书因此通过 my.cname.net 的 CName 连接到集群失败,因为该证书对该域无效。我们无法找到更改证书的任何方法,因此无法解决该问题,不得不坚持在连接中使用实际网络名称。
我正在使用 spring 数据中的 Lettuce 驱动程序连接到使用传输中加密的 ElastiCache。当我尝试连接到分配给 ElastiCache 集群的 Route53 CName 时。我收到此错误:
Caused by: com.lambdaworks.redis.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host='my.cname.net', port=6379]]
at com.lambdaworks.redis.cluster.RedisClusterClient.loadPartitions(RedisClusterClient.java:507)
at com.lambdaworks.redis.cluster.RedisClusterClient.initializePartitions(RedisClusterClient.java:481)
at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterAsyncImpl(RedisClusterClient.java:335)
at com.lambdaworks.redis.cluster.RedisClusterClient.connectClusterAsync(RedisClusterClient.java:273)
at org.springframework.data.redis.connection.lettuce.LettuceClusterConnection.doGetAsyncDedicatedConnection(LettuceClusterConnection.java:1250)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getAsyncDedicatedConnection(LettuceConnection.java:3466)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getDedicatedConnection(LettuceConnection.java:3487)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.getConnection(LettuceConnection.java:3460)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.sMembers(LettuceConnection.java:1998)
... 24 common frames omitted
这是我用来连接的代码:
@Bean
public static RedisConnectionFactory connectionFactory() {
Map<String, Object> source = Maps.newHashMap();
source.put("spring.redis.cluster.nodes", "my.cname.net:6379");
RedisClusterConfiguration clusterConfiguration = new RedisClusterConfiguration(new MapPropertySource("RedisClusterConfiguration", source));
clusterConfiguration.setMaxRedirects(10);
LettuceConnectionFactory factory = new LettuceConnectionFactory(clusterConfiguration);
factory.setValidateConnection(false);
factory.setUseSsl(true);
return factory;
}
现在,当我将 Cname 替换为附加到 ElastiCache 集群的实际网络名称时,程序可以正常工作。有谁知道为什么程序只在使用 Cname 时失败?
我们在 .NET 客户端上遇到了非常相似的问题。我认为问题是因为 Redis 端点用于 amazonaws.com 域的证书因此通过 my.cname.net 的 CName 连接到集群失败,因为该证书对该域无效。我们无法找到更改证书的任何方法,因此无法解决该问题,不得不坚持在连接中使用实际网络名称。