简体   繁体   English

我可以在前端 javascript 中使用纯 grpc(不是 grpc-web)吗

[英]Can I use pure grpc (not grpc-web) in frontend javascript

According to https://grpc.io/blog/state-of-grpc-web/根据https://grpc.io/blog/state-of-grpc-web/

It is currently impossible to implement the HTTP/2 gRPC spec3 in the browser, as there is simply no browser API with enough fine-grained control over the requests.目前不可能在浏览器中实现 HTTP/2 gRPC spec3,因为根本没有浏览器 API 对请求进行足够细粒度的控制。 For example: there is no way to force the use of HTTP/2, and even if there was, raw HTTP/2 frames are inaccessible in browsers.例如:没有办法强制使用 HTTP/2,即使有,浏览器也无法访问原始 HTTP/2 帧。

However caniuse says most of the browsers have http/2 implementation.然而caniuse说大多数浏览器都有 http/2 实现。

Is it still impossible to use pure grpc in frontend javascript?前端javascript还是不能用纯grpc吗? If it is, why?如果是,为什么?

As that caniuse page shows, browsers are able to communicate with HTTP/2 servers.正如 caniuse 页面所示,浏览器能够与 HTTP/2 服务器通信。 But the gRPC protocol does not just use the HTTP/2 protocol, it uses HTTP/2 in a specific way.但是 gRPC 协议不只是使用 HTTP/2 协议,它以特定的方式使用 HTTP/2。 The problem is that browsers do not provide the JavaScript APIs that are necessary to control the use of HTTP/2 in the ways that are required by the gRPC specification.问题是浏览器不提供 JavaScript API,这些 API 是按照 gRPC 规范要求的方式控制 HTTP/2 使用所必需的。 In particular, trailers are an important part of the gRPC protocol, and they are not generally accessible in browser HTTP/2 APIs.特别是,预告片是 gRPC 协议的重要组成部分,它们通常无法在浏览器 HTTP/2 API 中访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM