Stackexchange.redis: It was not possible to connect to the redis server(s). There was an authentication failure...

Created on 15 May 2020  ·  3Comments  ·  Source: StackExchange/StackExchange.Redis

Hi guys,

I'm using StackExchange.Redis version 2.1.30 to connect to an Azure Hosted Redis.
I am getting the following exceptions:
1) when I try to SET a string value (~6.5 KB):
_ProblemId_: **System.Net.Sockets.SocketException at StackExchange.Redis.ExtensionMethods.AuthenticateAsClient**
No connection is active/available to service this operation: SET <key>; A blocking operation was interrupted by a call to WSACancelBlockingCall, mc: 1/1/0, mgr: 10 of 10 available, clientName: <client-name>, IOCP: (Busy=2,Free=998,Min=2,Max=1000), WORKER: (Busy=1,Free=32766,Min=2,Max=32767), v: 2.1.30.38891

2) when I try to GET a string value:
_ProblemId_: **StackExchange.Redis.RedisConnectionException at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl**
No connection is active/available to service this operation: GET <key>; It was not possible to connect to the redis server(s). There was an authentication failure; check that passwords (or client certificates) are configured correctly. ConnectTimeout, mc: 1/1/0, mgr: 10 of 10 available, clientName: <client-name>, IOCP: (Busy=2,Free=998,Min=2,Max=1000), WORKER: (Busy=1,Free=32766,Min=2,Max=32767), v: 2.1.30.38891

Note: I am only getting these exceptions when I run the ASP.NET Web Services application from my CI and Stage environment (did't go to prod yet). If I run the application locally, it works (tried to connect to both CI and Stage redis services). Also, for testing purposes, I created a simple redis client console application that I deployed on the CI environment, and using the console application, I can successfully connect to Redis. Note that I used the exact same approach to connect to redis as per the ASP.NET Web Services application.

Connection implementation:

public class RedisConnection
{
    private static readonly string _connectionString = "hostname:6380,password=<valid-password>,ssl=True,abortConnect=False"; //hard coded from web.config

    private static readonly Lazy<ConnectionMultiplexer> LazyConnection;

    static RedisConnection()
    {
        LazyConnection = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(_connectionString));
    }

    public static ConnectionMultiplexer Connection => LazyConnection.Value;

    public static IDatabase RedisCache => Connection.GetDatabase();
}

And then use it as

...
private readonly IDatabase _redis = RedisConnection.RedisCache;
...

Any help would be much appreciated.

Filip

Most helpful comment

what framework is this? two thoughts occur:

All 3 comments

what framework is this? two thoughts occur:

Thanks for your fast reply, @mgravell . It's an ASP.NET ASMX Web Service project. It was appending the ,sslprotocols=tls12 to the connection string that fixed the issue. There's a min TLS version setting in Azure set to TLS12 but I ignored it since it worked from a console app on the same machine, with the same connection string.

This issue can be now closed. Thank you once again, @mgravell. Cheers!

it worked from a console app on the same machine

Different runtimes / framework versions, probably :)

Was this page helpful?
0 / 5 - 0 ratings