Google上对于c#如何使用Grpc的文档:

Protocol Buffer Basics: C# | Protocol Buffers | Google Developers

微软文档:

.NET Core 上的 gRPC 的简介

Grpc协议可以在不同平台和不同语言的客户端通讯;

但是由于浏览器和代理的能力限制,需要使用GrpcWeb协议;

https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md

DotnetCore 本身支持直接发布两种协议的Endpoint;

客户端JS的库:

grpc/grpc-web

1
protoc -I . helloworld.proto --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.

生成ts:

1
protoc -I . helloworld.proto --js_out=import_style=commonjs:. --grpc-web_out=import_style=typescript,mode=grpcwebtext:.

ts版本应该在3.7以上,否则会因为 // @ts-nocheck 被忽略造成编译不通过。