WatsonWebsocket icon indicating copy to clipboard operation
WatsonWebsocket copied to clipboard

StartWithTimeoutAsync fails the second try.

Open xbarra opened this issue 1 year ago • 0 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()

xbarra avatar Sep 23 '22 15:09 xbarra