Skip to content

Commit

Permalink
Move create Client into while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
JulanDeAlb committed Dec 12, 2023
1 parent 7d9d00b commit f0d553b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/TwitchLib.Communication/Clients/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,17 @@ private async Task<bool> OpenPrivateAsync(bool isReconnect)
return true;
}

// Always create new client when opening new connection
Client = CreateClient();

var first = true;
Options.ReconnectionPolicy.Reset(isReconnect);

while (!IsConnected &&
!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);
Expand Down

0 comments on commit f0d553b

Please sign in to comment.