Skip to content

HTTP/2 extended connect error message doesn't blame the server #111470

Closed

Description

@Mrgaton

Description

System.Net.Http.HttpRequestException: Failed to establish web socket connection over HTTP/2 because extended CONNECT is not supported. Try to downgrade the request version to HTTP/1.1.

Reproduction Steps

Conect to a websocket with Extended Connect

Expected behavior

Work?

Actual behavior

Exception

Regression?

No response

Known Workarounds

No response

Configuration

   conection = new ClientWebSocket();

   conection.Options.SetRequestHeader("Stream-Type", ",mystream");
   conection.Options.HttpVersion = HttpVersion.Version30;

   await conection.ConnectAsync(new Uri(webSocketUri), Net.client, CancellationToken.None);

Other information

No response

Activity

  1. dotnet-policy-service commented on Jan 15, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/ncl
    See info in area-owners.md if you want to be subscribed.

  2. MihaZupan commented on Jan 15, 2025

    @MihaZupan
    Member

    What server are you connecting to? You'll see that exception if it doesn't support HTTP/2 extended connects.

    As for HTTP/3, WebTransport is not supported by .NET yet, see #43641.

  3. Mrgaton commented on Jan 15, 2025

    @Mrgaton
    Author

    Im conecting to a httplistener wich is running net 9, but i gess that the problem was that extended connect was not suported on net 9 not on my server exception should be a bit more clear.

  4. MihaZupan commented on Jan 15, 2025

    @MihaZupan
    Member

    .NET 9 does support extended HTTP/2 connects.
    If you want to use WebSockets over H2, you'll have to switch to Kestrel. HttpListener isn't going to support anything modern, see #63941.

  5. Mrgaton commented on Jan 15, 2025

    @Mrgaton
    Author

    Okay but to clarify that the problem is onthe server would be great? i will see to migrate whole server

  6. MihaZupan commented on Jan 15, 2025

    @MihaZupan
    Member

    Tweaking the exception message to blame the server seems fine.
    We could also remove "Failed to establish web socket connection" from the error from HttpClient since we're just dealing with the extended connect at that layer. It's fine to include that at the WS layer.

  7. added this to the 10.0.0 milestone on Jan 15, 2025
  8. changed the title [-]Support Extended Connect for http2 and http3[/-] [+]HTTP/2 extended connect error message doesn't blame the server[/+] on Jan 15, 2025
  9. modified the milestones: 10.0.0, Future on Jan 15, 2025
  10. added
    help wanted[up-for-grabs] Good issue for external contributors
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Jan 15, 2025
  11. Mrgaton commented on Jan 15, 2025

    @Mrgaton
    Author

    I'm trying Kestrel and I see a lot of latency increase just in localhost where httplistener gets around 1-3 ms Kestrel gets around 90-110 ms

  12. MihaZupan commented on Jan 15, 2025

    @MihaZupan
    Member

    You're likely measuring the startup overhead (including jitting).
    If you're seeing actual performance problems with Kestrel when running benchmarks, please file an issue in https://github.com/dotnet/aspnetcore.

  13. Mrgaton commented on Jan 15, 2025

    @Mrgaton
    Author

    im measuring the web browser latency a bunch of times and that is the average i get

    Image

    when the simple httplistener gets aroun 1-3 as i said. try it yourself

  14. Boulea7 commented on Aug 11, 2026

    @Boulea7
  15. Boulea7 commented on Aug 11, 2026

    @Boulea7
  16. fzlzjerry commented on Aug 11, 2026

    @fzlzjerry
    Contributor

    I can take this. I’ll update the System.Net.Http-layer diagnostic to identify the HTTP/2 peer server as not supporting extended CONNECT, keep WebSocket-specific wording at the WebSocket layer, and extend the existing HTTP/2 loopback test to cover the message. Please assign it to me if useful.

  17. locked and limited conversation to collaborators on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions