After Redis restart, sometimes in ConnectionRestored event ConnectionMultiplexer.IsConnected is False
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.
Does anyone know why this happens?
I believe what you are observing might be related to issue #38
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.
@Xiaohongt I believe this was resolved long ago - are you still seeing anything like this? /cc @k0dem0nkey