socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
61.29k stars 10.12k forks source link

Add new transport: gRPC-Web #5068

Open thernstig opened 10 months ago

thernstig commented 10 months ago

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

darrachequesne commented 10 months ago

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:

thernstig commented 10 months ago

@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.