I am trying to make a simple example of reading and writing from azure redis cache and I get this error
An exception of type 'StackExchange.Redis.RedisConnectionException' occurred in StackExchange.Redis.dll but was not handled in user code
Additional information: It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
The code I am using is this, I changed dns and password
// Get Connection instance
ConnectionMultiplexer connection = ConnectionMultiplexer
.Connect("xx.redis.cache.windows.net,ssl=false,password=...");
// Get database
IDatabase databaseCache = connection.GetDatabase();
// Add items
databaseCache.StringSet("foo1", "1");
databaseCache.StringSet("foo2", "2");
// Add items with experation value
databaseCache.StringSet("foo3", "3", TimeSpan.FromMinutes(20));
Stopwatch sw = new Stopwatch();
sw.Start();
// Get item value
string foo1Value = databaseCache.StringGet("foo1");
sw.Stop();
Console.WriteLine("Elapsed={0}", sw.Elapsed);
return View();
Old message: "To create a disconnected multiplexer, disable AbortOnConnectFail." New message proposal: "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."
Firewall restriction is another common reason that can trigger the “could not connect to Redis connection refused”. By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.
You can download the latest version of Redis from https://redis.io/download. Redis can be installed on any server. In this case we'll install it locally for testing. to make Redis start automatically, and re-start when the computer reboots.
Azure Redis Cache only enables the SSL endpoint by default. The most secure approach is to set "ssl=true" when calling ConnectionMultiplexer.Connect().
Alternatively, you can use the Azure Portal to enable the non-SSL endpoint on your Azure Redis Cache, but then your password and all data will be sent in clear text.
I had exact same exception and it turned out to be corporate firewall, which is blocking port 6379, 6380.
I copied my test console app in an environment outside company network and connection was successful. So if Redis server is running on the internet and your network is behind a firewall make sure the ports are open.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With