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

Implement Http/2 WebSockets #41558

Merged
merged 22 commits into from
Jun 8, 2022
Merged

Implement Http/2 WebSockets #41558

merged 22 commits into from
Jun 8, 2022

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented May 6, 2022

Fixes #7801

This adds support to Kestrel and the WebSocket middleware for HTTP/2 WebSockets. It's enabled by default in both layers and does not currently provide an opt-out. Browsers silently utilize HTTP/2 WebSockets when advertised by the server. HttpClient support is coming soon, when we have that we'll write some interop tests (#41895).

@Tratcher Tratcher changed the title Tratcher/h2ws Implement Http/2 WebSockets May 27, 2022
@Tratcher Tratcher marked this pull request as ready for review May 27, 2022 22:52
httpContext.Features.Set<IHttpExtendedConnectFeature>(new ConnectFeature()
{
IsExtendedConnect = true,
Protocol = "WebSocket",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we test sending and receiving data frames over the WebSocket and then gracefully closing it here? I understand that nothing should change relative to HTTP/1.1 WebSockets once you get the underlying Stream, but it's good to verify.

It's also tempting to open up the stream and connection windows in both directions Http2ConnectionTests and create a duplex Stream over the data frames for the request and wrap that in a client WebSocket so we can get better end-to-end testing of this scenario since we don't have any HttpClient or JS WebSocket based tests for the end-to-end. That'd be a more work, but probably not too much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to add more functional tests once the HttpClient implementation is available. Without that it's pretty hard to write any realistic tests. The client team has asked us to merge this ASAP so they can use it develop the client.

@Tratcher Tratcher merged commit b14c9b8 into dotnet:main Jun 8, 2022
@Tratcher Tratcher deleted the tratcher/h2ws branch June 8, 2022 17:18
@ghost ghost added this to the 7.0-preview6 milestone Jun 8, 2022
captainsafia pushed a commit to captainsafia/aspnetcore that referenced this pull request Jun 13, 2022
@adityamandaleeka adityamandaleeka added the blog-candidate Consider mentioning this in the release blog post label Jun 18, 2022
@ghost
Copy link

ghost commented Jun 18, 2022

@Tratcher, this change will be considered for inclusion in the blog post for the release it'll ship in. Nice work!

Please ensure that the original comment in this thread contains a clear explanation of what the change does, why it's important (what problem does it solve?), and, if relevant, include things like code samples and/or performance numbers.

This content may not be exactly what goes into the blog post, but it will help the team putting together the announcement.

Thanks!

@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
@amcasey amcasey mentioned this pull request Sep 21, 2023
amcasey added a commit to amcasey/aspnetcore that referenced this pull request Sep 21, 2023
As of dotnet#41558, four settings are expected, not three.

Bonus: Actually show the http2cat logging
amcasey added a commit that referenced this pull request Sep 21, 2023
* Fix http2cat sample

As of #41558, four settings are expected, not three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions blog-candidate Consider mentioning this in the release blog post
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kestrel support for WebSockets over HTTP/2
9 participants