Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocketTests.FalseUpgradeTest fails when DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT=1 #371

Closed
davidni opened this issue Aug 19, 2020 · 3 comments
Assignees
Labels
Type: Bug Something isn't working
Milestone

Comments

@davidni
Copy link
Contributor

davidni commented Aug 19, 2020

Describe the bug

Unit test WebSocketTests.FalseUpgradeTest fails on both netcoreapp3.1 and netcoreapp5.0 when environment variable DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT=1.

This is likely by design at the moment (in which case having this issue around will help future people who may hit this). YARP currently always attempts to issue outgoing calls as HTTP/2. And when this env var is set, the outgoing HTTP stack will indeed honor that and issue an HTTP2 unencrypted request. However the simulated target server tries to handle it as HTTP/1.1 (which makes sense, since there's no ALPN step without TLS).

To Reproduce

  • Set environment variable DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT=1
  • Run Microsoft.ReverseProxy.FunctionalTests unit tests

Unit test WebSocketTests.FalseUpgradeTest fails:

 Microsoft.ReverseProxy.WebSocketTests.FalseUpgradeTest
   Source: WebSocketTests.cs line 127
   Duration: 505 ms

  Message: 
    Assert.Equal() Failure
    Expected: OK
    Actual:   InternalServerError
  Stack Trace: 
    WebSocketTests.FalseUpgradeTest() line 154
    --- End of stack trace from previous location ---

Digging deeper, when ReverseProxy issues the outgoing request to the simulated target destination, the destination server is encountering the following exception from Kestrel:

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unrecognized HTTP version: ''
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpParser`1.RejectUnknownVersion(Int32 offset, ReadOnlySpan`1 requestLine)

Possible solutions

  1. Do not always attempt HTTP/2 on outbound requests; perhaps only attempt HTTP/2 if the outbound request is using https?
  2. Configure Kestrel on the target sample server in the functional test to use only HTTP/2? Doesn't seem sensible, as nobody (sane) should run WebSockets on HTTP/2 😄.

Further technical details

  • Latest master, commit 8841dac2a64b90a0eb6144f229885e832110bace
  • Platform: Windows 10
@davidni davidni added the Type: Bug Something isn't working label Aug 19, 2020
@Tratcher
Copy link
Member

Yup, by design. Note DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT was just removed from 5.0 in favor of a public API so we should be able to provide a better experience here: #282

@karelz karelz added this to the 1.0.0 milestone Sep 8, 2020
@ManickaP
Copy link
Member

This does not reproduce on 5.0.0-rc.1.20451.14 on which the current 5.0 tests run.
Problem is now isolated to netcoreapp3.1 target.

@ManickaP
Copy link
Member

ManickaP commented Sep 29, 2020

Since this doesn't reproduce on 5.0, I'm closing it. It's resolved by removal of the app switch/env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants