-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Hi,
In case the connection with Redis failed due to authentication failure (e.g. password is configured incorrectly due to key rotation),
the ConnectionFailureType that is returned is ConnectionFailureType.UnableToConnect.
My suggestion is in this case to return ConnectionFailureType.AuthenticationFailure
Thus, me as a client, can decide to disconnect Redis and retry with a new primary key that I have fetched.
The automatically retry mechanism of IMultiplexer would never success to connect with its own retry policy, but I don't want to catch any RedisConnectionException.
Is there any reason that the function returns ConnectionFailureType.UnableToConnect instead of ConnectionFailureType.AuthenticationFailure in this case?
StackExchange.Redis/src/StackExchange.Redis/ExceptionFactory.cs
Lines 392 to 403 in 51d2946
| internal static Exception UnableToConnect(ConnectionMultiplexer muxer, string failureMessage=null) | |
| { | |
| var sb = new StringBuilder("It was not possible to connect to the redis server(s)."); | |
| if (muxer != null) | |
| { | |
| if (muxer.AuthSuspect) sb.Append(" There was an authentication failure; check that passwords (or client certificates) are configured correctly."); | |
| else if (muxer.RawConfig.AbortOnConnectFail) sb.Append(" Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code."); | |
| } | |
| if (!string.IsNullOrWhiteSpace(failureMessage)) sb.Append(' ').Append(failureMessage.Trim()); | |
| return new RedisConnectionException(ConnectionFailureType.UnableToConnect, sb.ToString()); | |
| } |
Thanks,
Sagi