From f0d553b6cca3af1ee414c781467e82faf7853b89 Mon Sep 17 00:00:00 2001 From: JulanDeAlb <67780894+JulanDeAlb@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:36:30 +0100 Subject: [PATCH] Move create Client into while loop --- src/TwitchLib.Communication/Clients/ClientBase.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/TwitchLib.Communication/Clients/ClientBase.cs b/src/TwitchLib.Communication/Clients/ClientBase.cs index 0dfc91f..e03c0c3 100644 --- a/src/TwitchLib.Communication/Clients/ClientBase.cs +++ b/src/TwitchLib.Communication/Clients/ClientBase.cs @@ -237,9 +237,6 @@ private async Task OpenPrivateAsync(bool isReconnect) return true; } - // Always create new client when opening new connection - Client = CreateClient(); - var first = true; Options.ReconnectionPolicy.Reset(isReconnect); @@ -247,6 +244,10 @@ private async Task OpenPrivateAsync(bool isReconnect) !Options.ReconnectionPolicy.AreAttemptsComplete()) { Logger?.TraceAction(GetType(), "try to connect"); + + // Always create new client when opening new connection + Client = CreateClient(); + if (!first) { await Task.Delay(Options.ReconnectionPolicy.GetReconnectInterval(), CancellationToken.None);