socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Add new transport: gRPC-Web

Open thernstig opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. There is a new standard called gRPC-Web that could be used as a transport between a client (browser) and backend service.

https://grpc.io/blog/postman-grpcweb/

It might be nice to have that as an alternative for Socket.IO when setting up the socket?

Describe the solution you'd like Implement gRPC-Web

Describe alternatives you've considered https://developer.mozilla.org/en-US/docs/Web/API/WebTransport is an alternative, but gRPC-Web might arguably be more performant. Leave the power to the user to decide what to use as transport.

Additional context None

thernstig avatar Feb 02 '24 09:02 thernstig

That's an interesting idea, thanks for the heads-up :+1:

WebTransport is an alternative, but gRPC-Web might arguably be more performant.

Do you have any source for that claim? Given that gRPC is built on HTTP/2 (TCP), I would have thought that WebTransport (based on UDP) would be more performant.

References:

  • https://cloud.google.com/blog/products/api-management/understanding-grpc-openapi-and-rest-and-when-to-use-them?hl=en
  • https://www.infoq.com/articles/websocket-and-http2-coexist/
  • https://grpc.io/about/

darrachequesne avatar Feb 05 '24 10:02 darrachequesne

@darrachequesne when I read up more on this, I am not confident gRPC-Web is suitable for socket.io - at least not yet. It seems to require a proxy (Envoy). It is currently also only good for server streaming, not client streaming. So maybe close this issue and re-open in the future?

Regarding HTTP/2 (gRPC) vs WebTransport (UDP), only some future performance measurements could solve that. What I believe is that the gRPC serialization packs more information than e.g. JSON, hence less data, hence more performant. But do not take my word for it: I do not know.

thernstig avatar Feb 05 '24 12:02 thernstig