Azure Redis unable to connect to Redis servers

2019-07-07 06:50发布

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;
        }
    }

1条回答
祖国的老花朵
2楼-- · 2019-07-07 07:20

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.

查看更多
登录 后发表回答