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

Multiplexed websocket support #198

Open
jared2501 opened this issue May 29, 2018 · 10 comments
Open

Multiplexed websocket support #198

jared2501 opened this issue May 29, 2018 · 10 comments
Labels
enhancement help-wanted We'd like your help!

Comments

@jared2501
Copy link

Currently, if using grpc-web with client-streaming (and bi-directional) endpoints one has to use the the websocket implementation provided by grpc-web since no fetch implementation supports client streaming yet. The websocket implementation in grpc-web opens a websocket per stream. Since each websocket is a separate, long-lived TCP stream, Firefox currently allows a maximum of 6 websockets per host. It would be nice if multiple gRPC streams could be multiplexed over a single websocket.

A rough proposal for what this could look like:

  • Each websocket binary message becomes a tuple of (streamId, bodyBytes|controlFrame). The controlFrame would be used to signal protocol errors / end of stream.
  • The streamId provides a means to multiplex multiple connections over a single websocket. It would behave exactly like an HTTP/2 stream ID - clients generate successive odd numbers when initiating new streams (servers would generate successive even numbers, but would not be supported in grpc-web).
  • The headers included at the start of a stream would include a ":path" entry, rather than the path of the websocket being used.
@jared2501
Copy link
Author

I'm looking to build such a transport on an internal fork this week. If this proposal sounds good, I'd be happy to contribute it back.

@joa
Copy link

joa commented Jul 31, 2018

@jared2501: Did you make any progress or is there a repo where we'd could provide some support?

@johanbrandhorst
Copy link
Contributor

Bump, this would be a great addition.

@RobIsHere
Copy link

I stumbled across this project: https://github.com/rsocket/rsocket/blob/master/Protocol.md
They are also solving multiplexing on websocket and have a very sophisticated protocol definition.

@johanbrandhorst johanbrandhorst added enhancement help-wanted We'd like your help! labels Sep 8, 2018
@davedoesdev
Copy link

I stumbled across this issue, thought I'd mention in passing a couple of projects I did:

https://github.com/davedoesdev/bpmux
https://github.com/davedoesdev/primus-backpressure

They implement back-pressure and multiplexing over Primus (WebSocket) streams.

I don't think they're highly relevant here but thought I'd mention them in case you find something useful.

@anderspitman
Copy link

anderspitman commented Feb 7, 2019

I hadn't heard of rsocket before seeing @RobIsHere's comment, and not for lack of searching for something in this space. I've been working on what could be considered a very stripped down version of the same idea. After reading through their info I think rsocket would likely be a great solution if you want to implement this functionality.

@wuyuanyi135
Copy link

+1 on this feature. The connection limit forced me change the architecture of my project.

@Virtual-felix
Copy link

+1 it would be a very appreciable improvement

@jonnyreeves
Copy link
Contributor

jonnyreeves commented Nov 11, 2019 via email

@maciej-wolny
Copy link

Any updates on the topic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help-wanted We'd like your help!
Projects
None yet
Development

No branches or pull requests

10 participants