Connecting to Azure Redis Cache
Asked Answered
L

3

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?

Lelalelah answered 21/5, 2014 at 3:5 Comment(0)
I
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");
Infecund answered 21/5, 2014 at 6:17 Comment(7)
I have tried both these methods for the same error.Lelalelah
@Lelalelah that should work fine; the following test passes for me, and talks over SSL: pastie.org/9195704Interurban
And to echo; the full connection string of that is "redacted.redis.cache.windows.net,password=somebase64,ssl=True"Interurban
Actually, all 4 of these work, but the 2 non-SSL options are very much not recommended: pastie.org/9195716Interurban
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.Lelalelah
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.Gormand
@ElvisLives: You can try to connect over SSL using redis-cli.exe and stunnel.exe. See this blog post for instructions: blogs.msdn.com/b/webdev/archive/2014/05/12/…. If this works, then you know the issue is with StackExchange.Redis and not the server.Infecund
I
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
Illusive answered 30/4, 2015 at 5:42 Comment(0)
K
-1

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

"localhost, port:6379, password=value"
Karren answered 14/3, 2021 at 22:46 Comment(2)
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.Podagra
@DanielMann - you are really right, i sincerely apologize and i will pay more attention to answer in newer topics. sorryKarren

© 2022 - 2024 — McMap. All rights reserved.