skip to Main Content

Basically am using StackExchangeRedis client to connect to a Redis Cluster with 3 Nodes.

My configuration is the following:

            config.EndPoints.Add(IPAddress.Parse("Node1_IP"), port);
            config.EndPoints.Add(IPAddress.Parse("Node2_IP"), port);
            config.EndPoints.Add(IPAddress.Parse("Node3_IP"), port);

            config.Password = "password";

            config.DefaultDatabase = 0;

            config.ConnectTimeout = ConfigurationOptionsConnectTimeout;
            config.AsyncTimeout = ConfigurationOptionsConnectTimeout;

            config.ConnectRetry = InitialConnectRetries;
            config.ReconnectRetryPolicy = new ExponentialRetry(DeltaBackOffMilliseconds);

            config.AbortOnConnectFail = false;

Node1 HashSlot range is from 0-8191

Node2 HashSlot range is from 8192-16383

Node3 has no HashSlot range, it’s like a slave i guess.

Error:

StackExchange.Redis.RedisConnectionException: Endpoint Node1_IP:Port serving hashslot 14371 is
 not reachable at this point of time. Please check connectTimeout value. If it is low, try increasing it
 to give the ConnectionMultiplexer a chance to recover from the network disconnect. IOCP: 
(Busy=0,Free=1000,Min=6,Max=1000), WORKER: (Busy=0,Free=8191,Min=6,Max=8191), Local-CPU: n/a

Scenario:
Trying to store some key-value in the database.

The above error occurs when my key is hashed(based on Redis hash function) in a hash slot that belongs to Node2 hash slot range.
The keys that are hashed in Node 1 hash slot range are stored successfully.

IF I rearrange the endpoints in the configuration by adding Node2_IP firstly and Node1_IP secondly, then the keys that are hashed in Node2 hash slots can be stored successfully but the keys that are hashed in hash slot range of Node1 produce the same error respectively.

2

Answers


  1. I too faced this issue inconsistently, after increasing the connection timeout and setting the CommandFlags.DemandMaster (use this only if its a write operation)

    var options = ConfigurationOptions.Parse(host+":"+port);
    options.ConnectTimeout = 60000; //60secs
    
    ConnectionMultiplexer
    .Connect(options)
    .GetDatabase()
    .StreamAdd(KeyName, "key", "value", flags: CommandFlags.DemandMaster);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search