I am doing some tests with Grpc and I realize that there is this two types of channels, but I don't know the difference.
But when I am working with certificates, with Grpc.Net.Client.GrpcChannel I can set the certificates but I get an error that the DNS is not solved. If I use Grpc.Core.Channel, I can call to the service, but I get an error because of the certificates, with the error - HTTP/2 over TLS was not negotiated on an HTTP/2-only endpoint.
Which is the difference between the 2 channels?
Thanks.
Grpc.Core.Channel is based on C Core libraries that forms the base codebase for all the language variants it supports (C++,C#, PHP, Objective-C, Python, Ruby etc)
Grpc.Net.Client.GrpcChannel is built for.NET Core using the familiar HttpClient object which supports Http/2 now.
The Homepage of grpc-dotnet states that:
GRPC for .NET does not replace gRPC for C# (gRPC C# API over native C-core binaries). These implementations coexist and share many of the same APIs to avoid lock-in. There are currently no plans for one implementation to replace the other one. gRPC for C# is the recommended solution for frameworks that gRPC for .NET does not support, such as .NET Framework.
When you inspect the code for Grpc.Net.Client.GrpcChannel, you can see an internal Httpclient object being used to make async calls and cancel pending requests.
The code for Grpc.Core.Channel seems to delegate its calls to the natively generated grpc code. This is about as far as I got in the limited time I could spend on it.
Interestingly, in the ssl validation part of the Net.Client.GrpcChannel, it actually states that it uses HttpClient in the exception messaging.
if (!string.IsNullOrEmpty(rootCertificates) ||
keyCertificatePair != null ||
verifyPeerCallback != null)
{
throw new InvalidOperationException(
$"{nameof(SslCredentials)} with non-null arguments is not supported by {nameof(GrpcChannel)}. " +
$"{nameof(GrpcChannel)} uses HttpClient to make gRPC calls and HttpClient automatically loads root certificates from the operating system certificate store. " +
$"Client certificates should be configured on HttpClient. See https://aka.ms/AA6we64 for details.");
}