Reputation: 1795
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?
Upvotes: 15
Views: 18907
Reputation: 1
Have you tried using grpc-web? I believe it has a workaround to use http1.1 instead of 2.2.
there are some things to be aware of, like trailers and streaming which work a bit different because of http1.1 support for those features.
Upvotes: 0
Reputation: 678
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.
Upvotes: 1
Reputation: 370
No. The RPC call is done only over HTTP/2. This allows gRPC users to automatically leverage all the features of the protocol.
Upvotes: 4
Reputation: 1063013
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)
Upvotes: 14