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

Websocket over HTTP2 #8011

Open
re-thc opened this issue Jun 8, 2018 · 12 comments
Open

Websocket over HTTP2 #8011

re-thc opened this issue Jun 8, 2018 · 12 comments

Comments

@re-thc
Copy link

re-thc commented Jun 8, 2018

Hi, as per https://www.chromestatus.com/feature/6251293127475200 (think Firefox is looking into this too) is an enhancements to have Websockets served over HTTP2. Can this feature please be implemented?

https://tools.ietf.org/id/draft-mcmanus-httpbis-h2-websockets-00.html

Extracting the justification:

A server offering both HTTP/1.1 and WebSocket services can do so from the same instance and same port although they require separate TCP connections. Moving a server to HTTP/2 and WebSocket services requires a separate port and protocol stack for the sole purpose of bootstrapping WebSockets. This is a significant administrative burden and may not even be possible in the case of large amounts of deployed markup pointing at the old single name and port. Being able to bootstrap WebSockets from HTTP/2 allows one server, one port, and one TCP connection to be shared by both protocols.

@normanmaurer
Copy link
Member

@hc-codersatlas we love contributions that said its a draft 00 so maybe a bit early for it.

@rschmitt
Copy link

The latest draft of the spec is available here.

@seamlik
Copy link

seamlik commented Jan 20, 2019

(think Firefox is looking into this too)

Will be supported by Firefox 65.

@rnd4222
Copy link

rnd4222 commented May 22, 2019

Given that it is no longer a draft, is there any chances it would be implemented in netty?

@normanmaurer
Copy link
Member

@rnd4222 we love contributions... so if you feel you have the cycles go ahead. I am not sure when I will have time to look into it.

@infoLightspace
Copy link

Am up for the challenge. Am going through the draft.

@mostroverkhov
Copy link
Contributor

for @hc-codersatlas and others interested in topic - recently I've experimented with rfc8441, and sharing results on https://github.com/jauntsdn/netty-websocket-http2

@riyafa
Copy link
Contributor

riyafa commented Jan 31, 2022

@mostroverkhov why is this not a PR to netty?

@glennosss
Copy link

glennosss commented Apr 30, 2022

I recently implemented this, surprisingly with minimal effort. The hardest part of implementing was interestingly more due to how the current Websocket over HTTP/1 code was structured.

Current websocket code needs refactoring

The current Websocket over HTTP/1 code is overly coupled to HTTP/1 HttpRequest/etc.

It's fairly straight forward to separate the Websocket code so that it's separate from the HTTP/1 and HTTP/2 specific parts.

Websockets over HTTP/2

The first pull request someone should send in is simply to add;

  • public static final char SETTINGS_ENABLE_CONNECT_PROTOCOL = 8; to Http2CodecUtil
  • update Http2Settings to support this constant.

Adding this constant is the first step to adding Websocket over HTTP/2 support to netty. And if the previous refactoring is done, and some example code was provided, I don't think most people would have trouble enabling HTTP/2 websockets themselves.

The weirdest thing I found about Websockets over HTTP/2 is Chrome only establishes them if there's a current HTTP/2 connection it can multiplex over. If the server restarts or Chrome loses it's connection to the webserver, then Chrome will immediately (and annoyingly) default back to a HTTP/1 websocket connection. This means you must have a websocket server that also supports at least one HTTP request in order to support HTTP/2 websockets (further support for the argument that you shouldn't "optimistically setup your pipelines").

@glennosss
Copy link

glennosss commented May 1, 2022

@normanmaurer I'm recommending that two new incubator projects be created and wanted your thoughts.

Summary;

Ultimately in the future clients will prefer to connect using WebTransport (only supported by HTTP/3 for now), but fall back to Websockets if necessary.

I think the following repos should be created;

Current state

[netty-codec-http] contains "io.netty.handler.codec.http.websocketx" package.

Future state: netty-incubator-codec-websockets

[netty-codec-websockets-http1] initially containing copy of "io.netty.handler.codec.http.websocketx" package.
[netty-codec-websockets-http2]
[netty-codec-websockets-http3]
[netty-codec-websockets-common] Most of the code for WebSocketFrame's/etc will be moved here. But with no dependency on netty-codec-http, netty-codec-http2 or netty-codec-http3.

Eventually remove "io.netty.handler.codec.http.websocketx" package from netty-codec-http.

Future state: netty-incubator-codec-webtransport

[netty-codec-webtransport-http2]
[netty-codec-webtransport-http3]
[netty-codec-webtransport-common]

@KingMob
Copy link

KingMob commented Oct 16, 2023

What's the status of this?

According to https://wpt.fyi/results/websockets/opening-handshake/002.html%3Fwpt_flags%3Dh2?label=experimental&label=master&aligned, RFC 8441 is now supported by all browsers other than Safari.

@mostroverkhov Have you considered making your repo a PR to netty?

@clayly
Copy link

clayly commented Dec 16, 2023

We've also been seeing a trend of more 400 errors lately, perhaps clients are trying http2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests