Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use gRPC with HTTP/1.1 in .NET Core?

I have two network services - a gRPC client and gRPC server. Server is written in .NET Core, hence HTTP/2 for gRPC is enforced. Client however is a .NET Framework 4.7.2 web app hosted on IIS 8.5, so it only supports HTTP/1.1.

Since it will take some time to upgrade the client I was thinking if it is possible to use HTTP/1.1 instead of HTTP/2 on the server side, but I cannot find any information how to achieve that.

Is it possible to use HTTP/1.1 for gRPC server written in .NET Core? And if so - how?

like image 759
GrayCat Avatar asked Jan 16 '20 13:01

GrayCat


Video Answer


3 Answers

No, you cannot use gRPC on HTTP 1.1; you may be able to use the Grpc.Core Google transport implementation, however, instead of the managed Microsoft bits; this targets .NET Standard 1.5 and .NET Standard 2.0, so should work on .NET Core, and uses an OS-specific unmanaged binary (chttp2) for the transport.

For client-side, there is virtually no difference between the two; only the actual channel creation changes, between:

GrpcChannel.ForAddress(...)

with the Microsoft transport, and

new Channel(...)

with the Google transport. All of the rest of the APIs are shared (in Grpc.Core.Api)

like image 191
Marc Gravell Avatar answered Oct 21 '22 12:10

Marc Gravell


No. The RPC call is done only over HTTP/2. This allows gRPC users to automatically leverage all the features of the protocol.

like image 44
WhoKnows Avatar answered Oct 21 '22 11:10

WhoKnows


If you don't need client streaming, you can Use the gRPC-Web protocol. Here's how you would start a client and server for such a service.

https://learn.microsoft.com/en-us/aspnet/core/grpc/browser?view=aspnetcore-6.0

Keep in mind that while it mentions blazor, this approach can be used in non-webassembly clients.

like image 1
MHDante Avatar answered Oct 21 '22 10:10

MHDante