Skip to content

[HTTP/3] Connection not closed when client is disposed? #56766

Closed

Description

@JamesNK

I have a test that:

  1. Creates a HttpClient
  2. Uses HttpClient to call Kestrel (this creates a QUIC connection)
  3. Disposes HttpClient (expect QUIC connection to be closed)

I expected that step 3 would trigger the client to send a GOAWAY and close the connection, and the server to receive a notification. The server has a pending call on AcceptStreamAsync that should throw. Instead, the connection stays open and the server patiently waits.

I wrote a test that uses QuicConnection directly and the expected abort happened on the server when the client called QuicConnection.CloseAsync.

Test in PR: dotnet/aspnetcore#34968
Test name: GET_ClientDisconnected_ConnectionAbortRaised

Client related code:

using (var host = builder.Build())
{
    await host.StartAsync();

    var client = CreateClient();
    try
    {
        var port = host.GetPort();

        // Act
        var request1 = new HttpRequestMessage(HttpMethod.Get, $"https://127.0.0.1:{port}/");
        request1.Version = HttpVersion.Version30;
        request1.VersionPolicy = HttpVersionPolicy.RequestVersionExact;

        var response1 = await client.SendAsync(request1);
        response1.EnsureSuccessStatusCode();

        await connectionStartedTcs.Task.DefaultTimeout();
    }
    finally
    {
        Logger.LogInformation("Disposing client.");
        client.Dispose();
    }

    Logger.LogInformation("Waiting for server to receive connection close.");
    await connectionClosedTcs.Task.DefaultTimeout();

    await host.StopAsync();
}

Activity

  1. ghost added
    untriaged
    on Aug 3, 2021
  2. wfurt commented on Aug 3, 2021

    @wfurt
    Member

    no pending requests? AFAIK HttpClient would keep active response streams alive even after disposal.

  3. JamesNK commented on Aug 3, 2021

    @JamesNK
    MemberAuthor

    There is a pending request. I'll check if that is the reason.

    No, there isn't a pending request.

  4. JamesNK commented on Aug 3, 2021

    @JamesNK
    MemberAuthor

    Maybe the client thinks the request has a response body (it doesn't) and is waiting for app code to finish reading it?

  5. removed
    untriaged
    on Aug 3, 2021
  6. added this to the 6.0.0 milestone on Aug 3, 2021
  7. geoffkizer commented on Aug 3, 2021

    @geoffkizer
    Contributor

    We are just missing this logic currently. I have a fix, will post a PR soon-ish.

  8. geoffkizer commented on Aug 6, 2021

    @geoffkizer
    Contributor

    Fixed by #56943

  9. ghost locked as resolved and limited conversation to collaborators on Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions