Skip to content

Commit

Permalink
Merge pull request #32 from JulanDeAlb/dev
Browse files Browse the repository at this point in the history
ConnectClientAsync - Fix "Cannot access a disposed object."
  • Loading branch information
Syzuna authored Jan 3, 2024
2 parents 7d9d00b + f0d553b commit 3ea0720
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 3ea0720

Please sign in to comment.