Reputation: 559
I have been searching for some time for a simple get / set example using C# and Azure Cache for Redis. I setup Azure Cache for Redis using default settings. I have the various Access Keys and have followed:
https://stackexchange.github.io/StackExchange.Redis/Basics.html
https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-overview
But I am not able to execute s simple get / set. I have installed the various package managers. My code is below:
using System;
using StackExchange.Redis;
using System.Configuration;
public class Redis
{
IDatabase db;
public Redis()
{
ConnectionMultiplexer redis = "conn-string-here");
this.db = redis.GetDatabase();
}
public void Set(string key, object value)
{
db.StringSet(key, value == null ? "" : value.ToString());
}
public string Get(string key)
{
return db.StringGet(key);
}
}
However, I keep getting this error message:
StackExchange.Redis.RedisConnectionException: No connection is active/available to service this operation: SET my_first_test_key; A blocking operation was interrupted by a call to WSACancelBlockingCall, mc: 1/1/0, mgr: 10 of 10 available, clientName: DESKTOP-78EDD5H, IOCP: (Busy=6,Free=994,Min=16,Max=1000), WORKER: (Busy=1,Free=8190,Min=16,Max=8191), v: 2.2.88.56325 ---> StackExchange.Redis.RedisConnectionException: SocketFailure on ZyelRedis.redis.cache.windows.net:6380/Subscription, Initializing/NotStarted, last: NONE, origin: ConnectedAsync, 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.2.88.56325 ---> System.IO.IOException: Unable to read data from the transport connection: A blocking operation was interrupted by a call to WSACancelBlockingCall.
Upvotes: 1
Views: 746
Reputation: 35
Double check your connection strings. The ones that show up in Azure may not include an important part, which is: sslprotocols=tls12
,
Example:
ZyelRedis.redis.cache.windows.net:6380,
password=k7e9OS5QzZ2XQPH9NktMiHCLpN3rTcMaPAzCaP3tnC0=,
ssl=True,
abortConnect=False,
sslprotocols=tls12
Requested: sslprotocols=tls12
Upvotes: 1