1

I am completely new to Redis and AWS ElastiCache service. I created a Redis cluster (5.0.6 v) with 1 Shard, 2 Nodes, No Encryption in-transit, No Encryption at-rest, No Redis Auth and Multi-AZ disabled.

I could see Primary Endpoint, Reader Enpoint and clicking on cluster, could see 2 node endpoints different than primary and reader endpoints.

I am using Lettuce with plain maven project to connect but getting Connection timeout. I tried with all combination of above endpoints no luck. I have added my ec2instance (where i am running code) to ElastiCache Subnet Groups. Still no luck.

Code Used:

RedisClusterClient clusterClient = RedisClusterClient.create(Arrays.asList(node1, node2));
StatefulRedisClusterConnection<String, String> connection = clusterClient.connect();
RedisAdvancedClusterAsyncCommands<String, String> asyncCommands = connection.async();

pom (only dependency):

 <dependency>
 <groupId>io.lettuce</groupId>
 <artifactId>lettuce-core</artifactId>
 <version>5.2.2.RELEASE</version>
 </dependency>

I have use case with plain java-maven and no frameworks like spring boot

Appreciate for help.

asked Jul 6, 2020 at 12:57

1 Answer 1

1

If some one looking for similar question of connecting to ElastiCache primary, this may help: Modifying security groups inbound traffic and with below model of client creation solved:

RedisURI upstreamUri = RedisURI.Builder.redis(primayNodeUrl, 6379).build();
RedisClient redisClient = RedisClient.create();
StatefulRedisMasterReplicaConnection<String, String> connection = 
MasterReplica.connect(
 redisClient,
 StringCodec.UTF8,
 upstreamUri);
connection.setReadFrom(ReadFrom.REPLICA_PREFERRED);
RedisAsyncCommands<String, String> asyncCommands = connection.async();
answered Jul 8, 2020 at 9:33
Sign up to request clarification or add additional context in comments.

1 Comment

Does this setup mean that you are reading from "Reader endpoint" and writing to "Primary endpoint"? I can't see you specify the static reader endpoint anywhere.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.