You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Do not always attempt HTTP/2 on outbound requests; perhaps only attempt HTTP/2 if the outbound request is using https?
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 😄.
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
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
DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_HTTP2UNENCRYPTEDSUPPORT=1
Unit test
WebSocketTests.FalseUpgradeTest
fails:Digging deeper, when ReverseProxy issues the outgoing request to the simulated target destination, the destination server is encountering the following exception from Kestrel:
Possible solutions
Further technical details
8841dac2a64b90a0eb6144f229885e832110bace
The text was updated successfully, but these errors were encountered: