StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

After Redis restart, sometimes in ConnectionRestored event ConnectionMultiplexer.IsConnected is False

Open Xiaohongt opened this issue 12 years ago • 4 comments

We use StackExchange.Redis in SignalR Redis scale-out, I found after Redis restart in ConnectionRestored event sometimes ConnectionMultiplexer.IsConnected is False, we need reading Redis Key in ConnectionRestored event handler, in this case it throw RedisConnectionException.

Here is simple repro app:

       private static ConnectionMultiplexer _connection;
        static void Main(string[] args)
        {
           string connectionString = "......";
            _connection = ConnectionMultiplexer.Connect(connectionString);

            _connection.ConnectionRestored += OnConnectionRestored;

            Console.ReadLine();
        }

        private static void OnConnectionRestored(object sender, ConnectionFailedEventArgs args)
        {
            Console.WriteLine("_connection.IsConnected is " + _connection.IsConnected);
        }

Repro steps: 1). Update connectionString for your Redis, build the app and run 2). Stop and Restart the Redis, look the console output, repeat this step until in output see: _connection.IsConnected is False

Expected result: in output it always should display "_connection.IsConnected is True" after Redis restart

Actual result: On my machine, after I restart Redis about 3 times, I can see " _connection.IsConnected is False" in output.

Xiaohongt avatar Jun 23 '14 03:06 Xiaohongt

Does anyone know why this happens?

Xiaohongt avatar Jun 26 '14 19:06 Xiaohongt

I believe what you are observing might be related to issue #38

coopa avatar Jun 26 '14 23:06 coopa

Although #38 has been closed, I'm seeing a similar issue in 1.0.316 (which may be related to this issue). My comment on that issue contains my observations, but I'm afraid no root cause/fix.

tekr avatar Aug 19 '14 06:08 tekr

@Xiaohongt I believe this was resolved long ago - are you still seeing anything like this? /cc @k0dem0nkey

NickCraver avatar Jan 26 '16 11:01 NickCraver