StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.86k stars 1.5k forks source link

Failed to connect to Sentinel cluster using Resp3 protocol #2591

Closed Alexander-Leontiev closed 8 months ago

Alexander-Leontiev commented 8 months ago

Hi!

StackExchange.Redis version 2.7.4 Redis server version 7.0.4

My connection string looks like the following: "redis1:26379, redis2:26379, redis3:26379, serviceName=mymaster, abortConnect=false". I connect like this: ConnectionMultiplexer.Connect(connectionString, logger). It works like a charm. But when i'm trying to activate new Resp3 protocol adding ", protocol=resp3" to the connection string things are going wrong. I see "StackExchange.Redis.RedisCommandException: This operation has been disabled in the command-map and cannot be used: HELLO" errors in my logs along with messages like "StackExchange.Redis.RedisConnectionException: UnableToConnect on redis1:26379/Interactive, Initializing/NotStarted, last: HELLO, ...".

Having investigated source code i found a couple of interesting places:

private ConnectionMultiplexer(ConfigurationOptions configuration, ServerType? serverType = null, EndPointCollection? endpoints = null) {
...
var map = CommandMap = configuration.GetCommandMap(serverType);
...
}

internal CommandMap GetCommandMap(ServerType? serverType) => serverType switch
        {
            ServerType.Sentinel => CommandMap.Sentinel,
            _ => CommandMap,
        };

public static CommandMap Sentinel { get; } = Create(new HashSet<string> {
            "auth", "ping", "info", "role", "sentinel", "subscribe", "shutdown", "psubscribe", "unsubscribe", "punsubscribe" }, true);

Looks like when the lib detects connection type as Sentinel, it overrides CommandMap with the value, which doesn't contain HELLO command. And i didn't manage to force HELLO availability any way. However according to https://redis.io/docs/management/sentinel/#sentinel-commands Sentinel supports HELLO.

Is it a bug in StackExchange.Redis or should i add some configuration / change the way of connection?

Alexander-Leontiev commented 8 months ago

@mgravell hi! Sorry for bothering, maybe you are already in progress of research on this issue. However I'd like to get some feedback, even if it will be preliminary and uncertain. Thank you!

NickCraver commented 8 months ago

Fixing this in #2601 :)