1
votes

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?

2
to clarify: when you say "web app" - do you mean from the browser? (both client/browser and server are part of the "web app")Marc Gravell
My Angular front end is running independantly of my .Net framework backend. Maybe web app is not the correct term here.Q-bertsuit
I think it should be possible as with any other gRPC service. You would just need Envoy to proxy HTTP calls to gRPC calls. See github.com/grpc/grpc-webdmaixner
@dmaixner Thanks! So just to be clear, it should be possible to do the following: JavaScrip front-end with gRPC -> Envoy proxy with gRPC-web -> .Net Framework with standard gRPCQ-bertsuit
yes,it's JS frontend with grpc-web (translates to http) -> envoy (translates http to grpc) -> grpc servicedmaixner

2 Answers

1
votes

The complete workflow would be like this:

  1. 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

  2. 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

  3. 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.

0
votes

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