Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis ConnectionMultiplexer.Connect() Intermittently Works

I am using StackExchange.Redis to talk to 3 different Redis instances: 1 on the same subnet and 2 remotely. Here's my configuration code:

var configurationOptions = new ConfigurationOptions
{
    EndPoints =
    {
        { host, port }
    },
    KeepAlive = 180,
    Password = password,
    DefaultVersion = new Version("2.8.5"),
    // Needed for cache clear
    AllowAdmin = true
};

var connectionMultiplexer = ConnectionMultiplexer.Connect(configurationOptions );

the last line throws a connection exception approximately 70% of the time:

It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail

Why is this intermittent and/or what am I doing wrong? When I ping the Redis server in a command prompt, there is 0% packet loss and a <1 ms response. The network is stable.

Thanks!

EDIT

Here is what the log outputs when it fails:

10.48.68.28:6379,keepAlive=180,version=2.8.5

1 unique nodes specified
Requesting tie-break from 10.48.68.28:6379 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:01 to respond...
10.48.68.28:6379 did not respond
10.48.68.28:6379 failed to nominate (WaitingForActivation)
No masters detected
10.48.68.28:6379: Standalone v2.8.5, master; keep-alive: 00:03:00; int: Connecting; sub: ConnectedEstablished, 1 active; not in use: DidNotRespond
10.48.68.28:6379: int ops=0, qu=4, qs=0, qc=0, wr=0, socks=1; sub ops=2, qu=0, qs=0, qc=0, wr=0, subs=1, sync=2, socks=1
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0+2=2 (0.20 ops/s; spans 10s)
Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago
Starting heartbeat...
like image 472
Haney Avatar asked Apr 18 '14 18:04

Haney


1 Answers

I was able to workaround it by setting a ConnectTimeouton the client when connecting to Redis. Here was my code

 ConnectionMultiplexer connection = 
        ConnectionMultiplexer.Connect("endpoint,password=password,ConnectTimeout=10000");
like image 191
pranav rastogi Avatar answered Sep 18 '22 13:09

pranav rastogi