8

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?

Craig
  • 36,306
  • 34
  • 114
  • 197

3 Answers3

12

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");
Mike Harder
  • 276
  • 3
  • 5
  • I have tried both these methods for the same error. – Craig May 21 '14 at 11:04
  • @Craig that should work fine; the following test passes for me, and talks over SSL: http://pastie.org/9195704 – Marc Gravell May 21 '14 at 11:42
  • And to echo; the full connection string of that is `"redacted.redis.cache.windows.net,password=somebase64,ssl=True"` – Marc Gravell May 21 '14 at 11:44
  • Actually, all 4 of these work, but the 2 non-SSL options are very much not recommended: http://pastie.org/9195716 – Marc Gravell May 21 '14 at 11:49
  • 3
    Those tests all fail for me, I have no ideal why. All I am doing is copying the name out of the cache name in the portal and the password is the Primary Key generated in the portal. – Craig May 21 '14 at 12:10
  • I couldnt't get the Azure Redis Cache to work over SSL a few days ago with a similar issue. I have a suspicious feeling it's something on the Azure side since it's in Preview. However I did get it working fine without SSL, but I was using the Service.Stack Redis library. – ElvisLives May 21 '14 at 23:06
  • @ElvisLives: You can try to connect over SSL using redis-cli.exe and stunnel.exe. See this blog post for instructions: http://blogs.msdn.com/b/webdev/archive/2014/05/12/announcing-asp-net-session-state-provider-for-redis-preview-release.aspx. If this works, then you know the issue is with StackExchange.Redis and not the server. – Mike Harder May 22 '14 at 20:02
1

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
Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
James Davis - MSFT
  • 1,736
  • 10
  • 12
-1

from local in C#, you can use like this ...

"localhost, port:6379, password=value"
Felipe Augusto
  • 1,341
  • 1
  • 16
  • 18
  • 1
    I downvoted this answer for a few reasons: 1) The question is 7 years old and received an accepted answer **the day** it was posted 7 years ago. 2) This isn't really an answer to the question *at all*, since the question is about Azure Redis as a service **not** locally-installed Redis. – Daniel Mann Mar 14 '21 at 23:33
  • 2
    @DanielMann - you are really right, i sincerely apologize and i will pay more attention to answer in newer topics. sorry – Felipe Augusto Mar 15 '21 at 02:12