I have found a very simple block of code to test if I'm able to connect to my Redis Cluster on ElastiCache
Here is the code:
using StackExchange.Redis;
Console.WriteLine("Hello, World!");
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("xxxxx.xxxxx.ng.0001.euw2.cache.amazonaws.com:6379,connectTimeout=30000,responseTimeout=30000,ssl=true,sslProtocols=tls12");
IDatabase db = redis.GetDatabase();
string value = "abcdefg";
db.StringSet("mykey", value);
string value1 = db.StringGet("mykey");
Console.WriteLine(value1);
This is the error I get:
StackExchange.Redis.RedisConnectionException HResult=0x80131500 Message=It was not possible to connect to the redis server(s). Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code. Source=StackExchange.Redis StackTrace: at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(ConfigurationOptions configuration, TextWriter log, Nullable`1 serverType, EndPointCollection endpoints) at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) at Program.
$(String[] args) in C:\Users\tracy\source\repos\stackexchangeRedis.test\stackexchangeRedis.test\Program.cs:line 5
So I added in "abortConnect=false", and now this is the new error:
StackExchange.Redis.RedisTimeoutException HResult=0x80131505 Message=Timeout performing SET (5000ms), inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Idle, in: 0, serverEndpoint: XXXXX.XXXX.ng.0001.euw2.cache.amazonaws.com:6379, mc: 1/1/0, mgr: 10 of 10 available, clientName: TRACY(SE.Redis-v2.6.66.47313), IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=0,Free=32767,Min=8,Max=32767), POOL: (Threads=9,QueuedItems=0,CompletedItems=37), v: 2.6.66.47313 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts) Source=StackExchange.Redis StackTrace: at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server, T defaultValue) at Program.
$(String[] args) in C:\Users\XXXX\source\repos\stackexchangeRedis.test\stackexchangeRedis.test\Program.cs:line 10
Useful information:
DotNet version: 6.0
StackExchange.Redis version: 2.6.66
I'm using visual studio 2022 on my local machine.
Redis cluster config: elasticache config