I am connecting .NET core app to AWS ElastiCache Redis.
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:
Any idea please?
NOTE: AWS Elasticache Redis is NOT available for public access as default.
redis-1.xxxx.0001.use1.cache.amazonaws.com:6379
is public available via security group (TCP\6379 for All IPs)? – beewest