Skip to content

Commit

Permalink
[#260] WebSocketTransportInitiator.ConnectAsync can result in Unobser…
Browse files Browse the repository at this point in the history
…vedTaskException
  • Loading branch information
xinchen10 committed Jun 11, 2024
1 parent 953aff4 commit 695f85a
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs c
cws.Options.SetBuffer(this.settings.ReceiveBufferSize, this.settings.SendBufferSize);
#endif

Task task = cws.ConnectAsync(this.settings.Uri, CancellationToken.None).WithTimeout(timeout, () => "timeout");
Task task = cws.ConnectAsync(this.settings.Uri, CancellationToken.None).WithTimeout(timeout, () => "Client WebSocket connect timed out");
if (task.IsCompleted)
{
callbackArgs.Transport = new WebSocketTransport(cws, this.settings.Uri);
Expand All @@ -40,10 +40,12 @@ public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs c
{
if (t.IsFaulted)
{
cws.Abort();
callbackArgs.Exception = t.Exception.InnerException;
}
else if (t.IsCanceled)
{
cws.Abort();
callbackArgs.Exception = new OperationCanceledException();
}
else
Expand Down

0 comments on commit 695f85a

Please sign in to comment.