It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING

Luis Valencia picture Luis Valencia · Mar 13, 2015 · Viewed 14.8k times · Source

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();

Answer

Mike Harder picture Mike Harder · Mar 13, 2015

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.