There are examples how to run in a browser, but they typically involve a sidecar proxy. Here is one example: https://github.com/grpc/grpc-experiments/tree/master/grpc-zpages The full docs are here: https://github.com/grpc/grpc-web
Browsers present two challenges to gRPC. First, they only use HTTP/2 when using TLS or SSL, which a lot of websites don't. Second, Browsers don't expose the HTTP trailers that are needed to tell when the response is done. To get around these issues, we have gRPC-Web protocol, which modifies the gRPC protocol slightly to be usable on HTTP/1.1. The fetch() API for Browsers was supposed to fix the latter problem, but it has not been implemented by them, so we are kinda stuck with the work around until they do. Lastly, browsers use CORS when making RPCs across origin, which happens when you serve your RPCs from a different port than you HTML. This may affect you depending on your setup. I guess all of this is to say that getting requests (or RPCs) to work in the browser is much more complicated that it first appears, and unfortunately we can't fix it for you. The proxy solution, while more complex, does solve a number of things you would have to otherwise do. On Wednesday, September 19, 2018 at 4:26:57 PM UTC-7, Greg Keys wrote: > > I was thrilled when I started looking at gRPC as an alternative to our > current implementation of websockets (crossbar.io) however that > enthusiasm is dwindling the more I look into it. > > Am I understanding this correctly that it's primary strength is server > side service to service communication? > > My hope was to use it in the browser as well as service to service. But > from what I gather the browser implementation is still using http/1.1 and > it does not multiplex as a result and instead uses xhr > > I have not been able to find any good (simple) examples of gRPC in the > browser, I've found a couple but they are really complex to reason about, > compared to the server side examples which are > typically really simple. > > Are there any good examples of gRPC in the browser? are there any > implementations in the browser that multiplex? > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/feb99493-f4ad-4bf9-a84c-4a02fb83620d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
