Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何连接azure redis? #142

Open
ghost opened this issue Apr 25, 2023 · 5 comments
Open

请问如何连接azure redis? #142

ghost opened this issue Apr 25, 2023 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 25, 2023

我使用freeredis连接azure redis时会爆出
System.Exception: '【xxx.redis.cache.chinacloudapi.cn:6380/0】状态不可用,等待后台检查程序恢复方可使用。Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..'

SocketException: An existing connection was forcibly closed by the remote host.
这样的错误
请问我使用freeredis该如何连接azure redis?

// 从azure redis获得的字符串
var conn="xxx.redis.cache.chinacloudapi.cn:6380,password=xxxx,ssl=True,abortConnect=False" ;
var cli=new RedisClient(conn)
@2881099
Copy link
Owner

2881099 commented Apr 25, 2023

min poolsize=1

连接串参考首页 readme

@ghost
Copy link
Author

ghost commented Apr 26, 2023

您好,感谢回复,但是我试了一下貌似还是不行
我在将连接字符串改为xxx.redis.cache.chinacloudapi.cn:6380,password=xxxx,ssl=True,minPoolSize=1后依然报同样的错误。
后来我尝试使用ConnectionStringBuilder

 var c = new ConnectionStringBuilder
        {
            Host = "xxxx.redis.cache.chinacloudapi.cn:6380",
            Password = "xxxxx",
            Ssl = true,
            MinPoolSize = 1
        };
 var cli = new RedisClient(c);
 cli.Set("key1", "value1");//此处开始抛异常

是我又忽略了什么吗?感谢

@2881099
Copy link
Owner

2881099 commented Apr 26, 2023

ssl=false

@2881099
Copy link
Owner

2881099 commented Apr 26, 2023

An existing connection was forcibly closed by the remote host..'

具体错误可以百度了解

@pjy612
Copy link

pjy612 commented Oct 26, 2023

前几天遇到相同问题 对 TLS/SSL 的 无法访问。
然后问了 作者 发现 之前 ssl 没启用 ,同步排查后,现在应该可以试试新版了。

不过目前应该还没支持 SslHost 的自行配置,所以 FreeRedis 连接的 host 要和 ssl 验证的 host 一致。

如果 做了 域名转发或映射 啥的 FreeRedis 目前可能还没支持,
那种可能暂时得用 StackExchange.Redis

var host = "abc.com:6380"
var conn = ConnectionMultiplexer.Connect($"{host},ssl=true,user={master.User},password={master.Password}", c =>
	{
		c.SslHost = "xxxx.redis.cache.chinacloudapi.cn";
	});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants