我正在使用StackExchange.Redis.StrongName 1.0.394
我正在尝试连接到我的 Azure Redis,但在运行项目时不断收到此错误:
RedisConnectionException: It was not possible to connect to the redis server(s);
to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING
奇怪的是,如果我使用 StackExchange.Redis 1.0.394
一切正常,但我需要 StrongName 版本才能使用 RedisSessionStateProvider。
以下是连接到 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;
}
}
最佳答案
我遇到了完全相同的异常,结果是公司防火墙阻止了端口 6379、6380。
我在公司网络外部的环境中复制了我的测试控制台应用程序,并且连接成功。 因此,如果 Redis 服务器在互联网上运行,并且您的网络位于防火墙后面,请确保端口打开。
关于c# - Azure Redis 无法连接到 Redis 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28725437/