Reputation: 3437
I know it's possible to set up a gRPC server and client scenario using only .Net Framework (two console applications for example). It is also possible to setup a web app client (in my case using Angular) and a .Net Core gRPC server app with the Grpc.AspNetCore.Web package.
However, is is possible to call a .Net framework gRPC service from a web app when it won't work with Grpc.AspNetCore.Web?
Upvotes: 1
Views: 1745
Reputation: 19
Asp.net Core 3.1 give us an option to directly communicate grpc through web without Envoy as proxy, you just need Grpc.AspNetCore.Web package 2.., I am using 2.31.0 https://www.nuget.org/packages/Grpc.AspNetCore.Web
Upvotes: 0
Reputation: 874
The complete workflow would be like this:
To your existing protoc
you would need to add protoc-gen-grpc-web
plugin: download from https://github.com/grpc/grpc-web/releases -- configuration options are here: https://github.com/grpc/grpc-web#client-configuration-options
You would need to start envoy
proxy (it's not the only option, but now it seems to be most used and supported), configuration seems to be complicated, but it's just verbose. Good starting point is here: https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/envoy.yaml
JS frontend just uses generated code, it can be as simple as this: https://github.com/grpc/grpc-web#3-write-your-js-client
Client is sending gRPC-web requests to Envoy (so you create usual gRPC messages and services in JS and those are translated to HTTP requests), Envoy translates this to regular gRPC call and sends it to your gRPC service. Similar for response.
Upvotes: 1