Skip to content

SignalR Core StartAsync() CancellationToken not respected? #10059

Closed
@vflame

Description

@vflame

Seems that the AspNetCore Signalr Client doesn't respect the cancellationtoken passed into the StartAsync() method. It will throw appropriately if the CTS timeout is sufficiently short (e.g., 1 millisecond);

Using this version of ASP.NET Core 3 Preview 5

var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1));
           var _hubConnection = new HubConnectionBuilder()
                .WithUrl(".WithUrl("http://slowwly.robertomurray.co.uk/delay/5000/url/http://www.google.co.uk")") //artificially slow, response times of ~5 seconds before a 404 is returned
                .Build();
           await _hubConnection.StartAsync(cts.Token);

Expected behavior

StartAsync() should throw an OperationCancelledException after 1 second. Any negotiation or handshake should be aborted if it was not already successfully completed within 1 second.

Current behavior

StartAsync() will wait until an HttpRequestException (in this case, a 404 after 5 seconds) is thrown or the connection succeeds. An OperationCancelledException is never thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedarea-signalrIncludes: SignalR clients and serversbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions