3
votes

I recently found out that there is the possibility of "Transcoding" the gRPC server so that it can receive HTTP/JSON requests as well as gRPC requests. I believe this will allow users to use the normal NetCore HTTP Client to send a request to a gRPC server (using protobuf of course). I have seen this implementation in other languages (mainly Go), but I have not been able to see anything on how this can be done in.NetCore and C#. Do you have any idea how this can be achieved?

This is the official Goggle documentation on the subject: https://cloud.google.com/endpoints/docs/grpc/transcoding

Thank You Very Much

1
I wonder if this might be better suited to an issue here: github.com/grpc/grpc-dotnet or github.com/grpc/grpcMarc Gravell

1 Answers

2
votes

I think the best way is to use the google api HTTP options and configure Envoy proxy to do the transcoding.

I got this working previously based on info on Christophe Hesters' blog.

However, deployment is a bit fiddly (especially on Windows, which is what I develop on).

The first method I used for debugging was:

  • Run WSL Ubuntu / WSL 2 Ubuntu / Ubuntu VM
  • Install docker in Linux
  • Run envoyproxy/envoy
  • Run your gRPC service manually on the host

You can use docker (desktop if on Windows) / docker-compose to make a more portable setup where Envoy and your service both run as containers.

Prompted by your question, I just discovered Microsoft.AspNetCore.Grpc.HttpApi. Its only a WIP preview for now, but looks to be a much easier option to get started with.