Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Azure Redis Cache

I am trying to connect to the Preview Azure Redis Cache with the following code.

var options = new ConfigurationOptions();
options.EndPoints.Add("myname.redis.cache.windows.net", 6379);
options.Ssl = true;
options.Password = "VeryLongKeyCopiedFromPortal";
var connection = ConnectionMultiplexer.Connect(options);

When I do this I get the exception

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

What can be causing this?

like image 417
Craig Avatar asked May 21 '14 03:05

Craig


2 Answers

The port for SSL is 6380. Port 6379 is used for non-SSL. StackExchange.Redis defaults to these ports if not set, so you should be able to just remove the port from your code, like so:

var options = new ConfigurationOptions();
options.EndPoints.Add("myname.redis.cache.windows.net");
options.Ssl = true;
options.Password = "VeryLongKeyCopiedFromPortal";
var connection = ConnectionMultiplexer.Connect(options);

Alternatively, you can use a connection string instead of the ConfigurationOptions object:

var connection = ConnectionMultiplexer.Connect(
    "myname.redis.cache.windows.net,ssl=true,password=VeryLongKeyCopiedFromPortal");
like image 171
Mike Harder Avatar answered Sep 19 '22 05:09

Mike Harder


I had this same issue. Make sure you copied the key correctly :)

My issue was I didn't copy the base 64 encoded key properly from the UI. Consider the two keys below. The way I usually copy/paste a non broken string is by double clicking. When I double clicked on the key I got the first set of data and not the entire string.

8Rs0Uvx7aaaaaaaaTjaoTu11bz0qOm/o5E8dtWPXtrc=
8Rs0Uvx7aaaaaaaaTjaoTu11bz0qOm
like image 26
James Davis - MSFT Avatar answered Sep 22 '22 05:09

James Davis - MSFT