1

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?

5
  • to clarify: when you say "web app" - do you mean from the browser? (both client/browser and server are part of the "web app") Commented Aug 18, 2020 at 11:09
  • My Angular front end is running independantly of my .Net framework backend. Maybe web app is not the correct term here. Commented Aug 18, 2020 at 12:55
  • 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-web Commented Aug 19, 2020 at 5:59
  • @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 gRPC Commented Aug 19, 2020 at 6:52
  • 1
    yes,it's JS frontend with grpc-web (translates to http) -> envoy (translates http to grpc) -> grpc service Commented Aug 19, 2020 at 9:15

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks alot for this! Quick follow up question: Envoy is a complete separate application, not a library that you can use directly in the service right?
Right. There are some others, but this one is most supported by grpc-web right now. Maybe there's something special for .NET, but I'm not familiar with that.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.