Reputation: 322
I can never store a string value to an Azure hosted Redis Cache. Using StackExchange.Redis version 2.0.601 and vs2015 and vs2019. Code below has error in comments (basically even with successful ConnectionMultiplexer.Connect there no connection is established).
static bool Connect()
{
ConnectionMultiplexer redis;
try
{
ConfigurationOptions cfgOptions = new ConfigurationOptions
{
EndPoints =
{
{"RedisOnMyAzureServer", myPort}
},
AbortOnConnectFail = false,
Ssl = true,
ConnectRetry = 3,
ConnectTimeout = 10000,
SyncTimeout = 10000,
DefaultDatabase = 0,
Password = "myPassword"
};
redis = ConnectionMultiplexer.Connect(cfgOptions); // takes 10.5 seconds on average
}
catch
{ return false; } // never errors
// some diagnostics follow
if (redis.IsConnected)
Console.WriteLine("client connection open");
else
Console.WriteLine("client connection closed");
if (redis.GetDatabase().IsConnected(default(RedisKey)))
Console.WriteLine("database connection open");
else
Console.WriteLine("database connection closed");
// both connection are always closed.
try
{
IDatabase db = redis.GetDatabase();
db.StringSet("mykey", "value");
}
catch
{ return false; } // always errors
return true;
}
Errors at last try/catch on db.StringSet method. I get this message:
No connection is available to service this operation: SET mykey; A blocking operation was interrupted by a call to WSACancelBlockingCall; IOCP: (Busy=0,Free=1000,Min=4,Max=1000), WORKER: (Busy=2,Free=1021,Min=4,Max=1023), Local-CPU: n/a
Upvotes: 2
Views: 1605
Reputation: 101
I got same error when I set minimum TLS version to 1.2 on Azure Redis Cache, and it was caused by TLS mismatch. It was resolved by following measures.
sslprotocols=tls12
to the connection stringTLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
to TLS cipher suitesHere is the details, Remove TLS 1.0 and 1.1 from use with Azure Cache for Redis
Upvotes: 10