From c2eeb7ab735c504a317c415c6766d2e927e4a9b2 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Sun, 1 Oct 2017 17:26:01 +0300 Subject: [PATCH] Don't lose Redis connection on reconnect Keep Redis connection stored so that it's not lost and we avoid reconnecting all the time. --- worker/src/Worker/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/worker/src/Worker/Program.cs b/worker/src/Worker/Program.cs index 634b937..78ccff4 100644 --- a/worker/src/Worker/Program.cs +++ b/worker/src/Worker/Program.cs @@ -31,7 +31,8 @@ namespace Worker // Reconnect redis if down if (redisConn == null || !redisConn.IsConnected) { Console.WriteLine("Reconnecting Redis"); - redis = OpenRedisConnection("redis").GetDatabase(); + redisConn = OpenRedisConnection("redis"); + redis = redisConn.GetDatabase(); } string json = redis.ListLeftPopAsync("votes").Result; if (json != null)