Search code examples
c#asp.netreactjssignalrgrpc

Can I use gRpc as a replacement of SignalR for updating notification on client-side?


I'm new to gRpc and now learning this tech

I'm wondering if gRpc can replace SignalR for updating notification bar on my client-side app (React). Is that the case? or should I keep using SignalR for this matter?

(I'm asking it just to make sure I understand the purpose of the gRpc tech, by few articles I read it's more a web API replacement and few others compare it to SignalR)

Thanks! y-me


Solution

  • Assuming you meant browser-based clients, then NO you cannot use gRPC. The gRPC protocol relies on HTTP/2 framing and in particular the ability to send and receive HTTP trailers. While browser themselves can and do use HTTP/2, current browser APIs (XHR/Fetch) don't expose HTTP/2 semantics.

    There is however an alternative protocol, gRPC-web, that supports a subset of gRPC functionality you can utilize from a browser-based application. Given that it is a different protocol, your server will need to support it or you will need to employ a proxy like Envoy that can translate gRPC-web calls to gRPC.