请问如何连接azure redis?
wangzhengxu opened this issue · 5 comments
我使用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)
min poolsize=1
连接串参考首页 readme
您好,感谢回复,但是我试了一下貌似还是不行
我在将连接字符串改为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");//此处开始抛异常
是我又忽略了什么吗?感谢
ssl=false
An existing connection was forcibly closed by the remote host..'
具体错误可以百度了解
前几天遇到相同问题 对 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";
});