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

Bootstrapping WebSockets with HTTP/2 #329

Open
lyarbean opened this issue Oct 18, 2021 · 3 comments
Open

Bootstrapping WebSockets with HTTP/2 #329

lyarbean opened this issue Oct 18, 2021 · 3 comments

Comments

@lyarbean
Copy link
Contributor

Suppose a web page has a script to create a new websocket,
then every tab that loads that page (at each time) will create a new websocket.
In HTTP1.1, a websocket is in fact a TCP socket connection :-(.
And browsers like chrome and firefox limit number of websocket connections.

Bootstrapping WebSockets with HTTP/2, as specified by https://tools.ietf.org/html/rfc8441,
allow multiple websockets to live in one Http2 connection, as a stream, and already gets supported by chrome and firefox.

However the work to support Websocket in Cutelyst seems not easy.
I noticed that the design of http2 is far different from http's, which stop my steps:
For Http

  1. ProtoRequestHttp is ProtocolData and EngineRequest
  2. ProtocolHttp is Protocol
  3. ProtocolWebSocket is Protocol

For Http2

  1. H2Stream is EngineRequest
  2. ProtoRequestHttp2 is ProtocolData
  3. ProtocolHttp2 is Protocol

@dantti , I would greatly appreciate it if you have plan to support it. Thanks!

@dantti
Copy link
Member

dantti commented Oct 18, 2021

You can probably do that using nginx as the frontend, I'm leaning towards HTTP/3 rather than this specially since I don't use and didn't saw real benefits in H2, rather than a very complex code to deal with it.

@dantti
Copy link
Member

dantti commented Oct 18, 2021

Still doesn't seem so hard to implement it anyway, you basically has to extend the ProtoRequestHttp2 with the new settings, and H2Stream with websocket virtual functions probably using ProtocolWebSocket to read/write messages.

@lyarbean
Copy link
Contributor Author

Still doesn't seem so hard to implement it anyway, you basically has to extend the ProtoRequestHttp2 with the new settings, and H2Stream with websocket virtual functions probably using ProtocolWebSocket to read/write messages.

Thanks, I got it. I will try later.

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

2 participants