Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do browsers not support gRPC?

Tags:

grpc

grpc-web

gRPC is based on HTTP/2, which (assumption) is widely supported by browsers. Therefore, I feel there should be no problem with gRPC from a browser.

However, it is clear that there is a problem. The protocol, grpc web, is different, as exists "due to browser limitation". There are also numerous blog post describing complicated tech stacks deployed to get gRPC to work from a browser.

I'm missing the actual problem - why does gRPC not simply work from browsers?

like image 526
tonicsoft Avatar asked Sep 06 '18 21:09

tonicsoft


People also ask

Does browsers support gRPC?

It's not possible to directly call a gRPC service from a browser. gRPC uses HTTP/2 features, and no browser provides the level of control required over web requests to support a gRPC client. gRPC on ASP.NET Core offers two browser-compatible solutions, gRPC-Web and gRPC JSON transcoding.

Is gRPC over HTTP or TCP?

gRPC uses HTTP/2, which multiplexes multiple calls on a single TCP connection. All gRPC calls over that connection go to one endpoint.

Why is gRPC-Web needed?

The web client of gRPC-Web allows for easier coordination between the browser and back end services of your application, and continues to provide compatibility wherever you implement the protocol. It also removes the need to configure separate HTTP clients between backend services and your application.

Do all browsers support http2?

In browsers, HTTP/2 is supported by the most current releases of Edge, Safari, Firefox and Chrome. Other browsers based upon Blink will also support HTTP/2 (e.g., Opera and Yandex Browser).


1 Answers

I now understand that browsers only supports HTTP/2 in the sense that they use it to fetch resources from the server on behalf of your application (javascript) code.

Javascipt application code can still only use HTTP/1 (which may be handled under the hood by the browser in an HTTP/2 connection). Therefore it is not possible for application code to use grpc.

If anyone should find where this is explained in the docs, it would be good to add a link to it here.

like image 168
tonicsoft Avatar answered Nov 14 '22 05:11

tonicsoft