蔚蓝的Redis无法连接到服务器的Redis [英] Azure Redis unable to connect to Redis servers
问题描述
我用 StackExchange.Redis.StrongName 1.0.394
键,我试图连接到我的Azure Redis的,但是当我跑我不断收到这个错误我项目:
RedisConnectionException:这是不可能连接到Redis的服务器(S);
以创建断开连接多路复用器,禁用AbortOnConnectFail。 SocketFailure上PING
奇怪的是,如果我用 StackExchange.Redis 1.0.394
一切工作正常,但我为了使用RedisSessionStateProvider需要强名称的版本。
下面是code,用于连接到Redis的:
私有静态ConnectionMultiplexer连接
{
得到
{
如果(_connection == NULL ||!_connection.IsConnected)
{
无功配置=新ConfigurationOptions();
config.EndPoints.Add(myredisname.redis.cache.windows.net);
config.Password =myverylongkey;
//在毫秒
config.SyncTimeout = 5000;
config.Ssl = TRUE;
config.AbortOnConnectFail = FALSE; _connection = ConnectionMultiplexer.Connect(配置);
} 返回_connection;
}
}
我有完全相同的异常,它竟然是公司的防火墙,该防火墙阻止端口6379,6380. 搜索
我复制了我的测试控制台应用程序环境中的企业网络之外,连接成功。
所以如果Redis的服务器在Internet上运行,你的网络是在防火墙后面,确保端口是开放的。
I'm using StackExchange.Redis.StrongName 1.0.394
And I'm trying to connect to my Azure Redis, but I keep getting this error when I run my project:
RedisConnectionException: It was not possible to connect to the redis server(s);
to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
Oddly enough, if I use StackExchange.Redis 1.0.394
everything works fine, but I need StrongName version in order to use RedisSessionStateProvider.
Here is code for connecting to Redis:
private static ConnectionMultiplexer Connection
{
get
{
if (_connection == null || !_connection.IsConnected)
{
var config = new ConfigurationOptions();
config.EndPoints.Add("myredisname.redis.cache.windows.net");
config.Password = "myverylongkey";
//in ms
config.SyncTimeout = 5000;
config.Ssl = true;
config.AbortOnConnectFail = false;
_connection = ConnectionMultiplexer.Connect(config);
}
return _connection;
}
}
I had exact same exception and it turned out to be corporate firewall, which is blocking port 6379, 6380.
I copied my test console app in an environment outside company network and connection was successful. So if Redis server is running on the internet and your network is behind a firewall make sure the ports are open.
这篇关于蔚蓝的Redis无法连接到服务器的Redis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!