Skip to content

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

@Xiaohongt

Description

@Xiaohongt

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions