StartWithTimeoutAsync fails the second try.
Closed this issue · 5 comments
Bug Report
Operating system and version: Windows 10
Framework and runtime: .NET 6.0
Nuget version 3.0.1
Issue encountered:
When I use StartWithTimeoutAsync
, after the first timeout, it fails with The WebSocket has already been started
Expected behavior:
The Client should try to start the connection again.
The same code works as expected in .Net Framework 4.8
Steps to reproduce:
Call StartWithTimeoutAsync
until connected.
Sample code encapsulating the problem:
while (!Connected)
{
try
{
await StartWithTimeoutAsync(30);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
Exception details:
System.InvalidOperationException: 'The WebSocket has already been started.'
StackTrace:
at System.Net.WebSockets.ClientWebSocketOptions.ThrowIfReadOnly()
at WatsonWebsocket.WatsonWsClient.SetInvalidCertificateAcceptance()
at WatsonWebsocket.WatsonWsClient.<StartWithTimeoutAsync>d__51.MoveNext()
Hi @xbarra I just published v3.0.2, could you give it a whirl? I also added the Test.ClientTimeout
project to test this issue. Please re-open if the issue persists!
NuGet: https://www.nuget.org/packages/WatsonWebsocket/3.0.2
Commit: affc63f
Hi @jchristn,
Don't
Hi @xbarra sorry for the delay, just reproduced this, and looking into it now.
Don't worry!
Hi @xbarra I just published v3.0.2, could you give it a whirl? I also added the
Test.ClientTimeout
project to test this issue. Please re-open if the issue persists!NuGet: https://www.nuget.org/packages/WatsonWebsocket/3.0.2 Commit: affc63f
It is working perfectly now, thank you very much!
By the way, as a workaround, I had set AcceptInvalidCertificates = false
.
Sorry for not mentioned that earlier, it could had saved you some debugging time.
And while checking why it was working in .Net Framework 4.8, I noticed that it was not entering in the if at line 571.
Do you want me to open an issue for this?