-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Handle web socket downgrade when HTTP/2 not enabled #73843
Handle web socket downgrade when HTTP/2 not enabled #73843
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDuring manual testing of #73762 @BrennanConroy and me detected that in the case when HTTP/2 connection is not supported downgrade for web sockets is not working as expected. In that case However, it doesn't handle plain text scenario because HttpClient in that case silently create Http2Connection with no chance to detect the real version before we try to establish extended connect. If downgrade allowed by policy HttpClient force 1.1 without giving 2.0 a try -- maybe ClientWebSocket should do the same.
|
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Show resolved
Hide resolved
…andler/HttpConnectionPool.cs Co-authored-by: Natalia Kondratyeva <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Yes, ClientWebSocket should follow the same rules as HttpClient here. |
I agree we should match runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs Lines 1037 to 1039 in 3db2ebf
If the scheme is not secure and the policy allows 1.1, we should not attempt 2.0. |
I added condition to force to 1.1 non-secure web socket requests in ClientWebSocket @MihaZupan @Tratcher |
Does HTTP/2 over cleartext work with WebSockets right now? SocketsHttpHandler requires that you use set both Version=2.0 and Policy=Exact for that. Line 73 in feb0e27
|
VersionPolicy is set up later in the Line 370 in feb0e27
|
/azp run runtime-libraries-coreclr outerloop |
This comment was marked as outdated.
This comment was marked as outdated.
b8d1c66
to
630bd7a
Compare
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Failures in the outerloop builds are unrelated |
During manual testing of #73762 @BrennanConroy and me detected that in the case when HTTP/2 connection is not supported downgrade for web sockets is not working as expected.
In that case
ClientWebSocket
didn't get exception data indicating that downgrade is possible, so I added this data and tests for it.However, it doesn't handle plain text scenario because HttpClient in that case silently create Http2Connection with no chance to detect the real version before we try to establish extended connect. If downgrade allowed by policy HttpClient force 1.1 without giving 2.0 a try -- maybe ClientWebSocket should do the same.