From 3d34e490a94075a9a81c71e6ecaeec92471bbe09 Mon Sep 17 00:00:00 2001 From: RogueException Date: Wed, 27 Jul 2016 20:54:47 -0300 Subject: [PATCH] Added jitter to reconnect because abala --- src/Discord.Net/DiscordSocketClient.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Discord.Net/DiscordSocketClient.cs b/src/Discord.Net/DiscordSocketClient.cs index 12a988336..c85807aba 100644 --- a/src/Discord.Net/DiscordSocketClient.cs +++ b/src/Discord.Net/DiscordSocketClient.cs @@ -269,13 +269,14 @@ namespace Discord { try { + Random jitter = new Random(); int nextReconnectDelay = 1000; while (true) { await Task.Delay(nextReconnectDelay, cancelToken).ConfigureAwait(false); - nextReconnectDelay *= 2; - if (nextReconnectDelay > 30000) - nextReconnectDelay = 30000; + nextReconnectDelay = nextReconnectDelay * 2 + jitter.Next(-250, 250); + if (nextReconnectDelay > 60000) + nextReconnectDelay = 60000; await _connectionLock.WaitAsync().ConfigureAwait(false); try