c# - Azure Redis 无法连接到 Redis 服务器

标签 c# asp.net-mvc azure redis stackexchange.redis

我正在使用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/

相关文章:

c# - 当我的 IValueConverter 抛出异常时,如何运行 IDataErrorInfo 验证代码?

c# - 无法在 C# 中序列化数组对象

c# - 当通过 .NET Compact 从 C# 向同一 Java 服务器发出两个 HttpWebRequest 时,出现 "Request timed out"

c# - MVC5 EF6 CodeFirst 使用两个数据库进行调试和发布

c# - Entity Framework 工作单元生命周期

Azure,没钱时关闭所有虚拟机

c# - 从网页发送文档到打印机

python - Azure Blob 的交互式凭据

asp.net-mvc - 如何获取 Azure 自动化客户端的证书

asp.net-mvc - 仍然迷失在存储库和解耦,ASP.NET MVC