0
votes

I am connecting .NET core app to AWS ElastiCache Redis. enter image description here

The AWS Elasticache Redis is running and port 6329 is open on security group. The client code is using StackExchange.Redis:

           var redis = ConnectionMultiplexer.Connect("redis-1.xxxx.0001.use1.cache.amazonaws.com:6379");
           //var redis = ConnectionMultiplexer.Connect("localhost"); //working
           IDatabase db = redis.GetDatabase();

            string value = "abcdefg";
            db.StringSet("mykey", value);        

            string value2 = db.StringGet("mykey");
            Console.WriteLine(value2); // writes: "abcdefg"

            Console.ReadLine();

Exception is:

It was not possible to connect to the redis server(s). UnableToConnect on redis-1.xxx.0001.use1.cache.amazonaws.com:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.601.3402

Added to ,abortConnect=false to the endpoint, I am able to connect.

Now the error is at StringSet

StackExchange.Redis.RedisConnectionException: 'No connection is available to service this operation: SET mykey; UnableToConnect ...

The .NET code is working fine with my local Redis service so looks like something incorrect with my AWS setup.

Successfully ssh to my EC2-instance and redis-cli to my AWS redis service: enter image description here

Any idea please?

NOTE: AWS Elasticache Redis is NOT available for public access as default.

1
Maybe try connecting to the server using redis-cli from your workstation?Trinopoty
successfully ssh into a ec2-instance and run redis-cli againt my aws redis service. But still failed from .net app (docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/…)beewest
Just to be clear, you're getting this error when you deploy your code to the same EC2 instance? In that case, there shouldn't be any issues since the redis-cli can connect fine.Trinopoty
I am running .net code from my machine. Thought redis-1.xxxx.0001.use1.cache.amazonaws.com:6379 is public available via security group (TCP\6379 for All IPs)?beewest
Try to connect to your redis server from your own machine then with redis-cli, not from the EC2.Trinopoty

1 Answers

0
votes

Question: "...port 6329 is open on security group.." Dont you mean 6379?

Even that, i think i cn have an issue on the "default" subnet groups.

Does the VPC_Subnet (in that group) where the AWS ElastiCache Redis is, has a Routing Table with access to the Internet Gateway? If not, you need to attache the InternetGteway to the Route Table and than use that Route Table on the Subnet that you want.

It should be like the pick: Internet GW