简体   繁体   English

Grpc.Core.Channel 和 Grpc.Net.Client.GrpcChannel 之间的区别是什么?

[英]which is the difference between Grpc.Core.Channel and Grpc.Net.Client.GrpcChannel?

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.我正在用 Grpc 做一些测试,我意识到有这两种类型的渠道,但我不知道有什么区别。

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.但是当我使用证书时,使用 Grpc.Net.Client.GrpcChannel 我可以设置证书,但我收到一个错误,表明 DNS 没有解决。 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.如果我使用 Grpc.Core.Channel,我可以调用该服务,但由于证书问题,我收到错误消息 - 基于 TLS 的 HTTP/2 未在仅 HTTP/2 的端点上协商。

Which is the difference between the 2 channels? 2个通道有什么区别?

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.Core.Channel 基于 C 核心库,它构成了它支持的所有语言变体(C++、C#、PHP、Objective-C、Python、Ruby 等)的基本代码库

Grpc.Net.Client.GrpcChannel is built for.NET Core using the familiar HttpClient object which supports Http/2 now. Grpc.Net.Client.GrpcChannel 是为 .NET Core 使用熟悉的 HttpClient 对象构建的,该对象现在支持 Http/2。

The Homepage of grpc-dotnet states that: grpc-dotnet的主页指出:

GRPC for .NET does not replace gRPC for C# (gRPC C# API over native C-core binaries).适用于 .NET 的 GRPC 不会替换适用于 C# 的 gRPC(基于原生 C 核二进制文件的 gRPC C# API)。 These implementations coexist and share many of the same APIs to avoid lock-in.这些实现共存并共享许多相同的 API 以避免锁定。 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. gRPC for C# 是 gRPC for .NET 不支持的框架的推荐解决方案,例如 .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.当您检查 Grpc.Net.Client.GrpcChannel 的代码时,您可以看到一个内部 Httpclient对象用于进行异步调用和取消挂起的请求。

The code for Grpc.Core.Channel seems to delegate its calls to the natively generated grpc code. Grpc.Core.Channel 的代码似乎将其调用委托给本机生成的 grpc 代码。 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.有趣的是,在 Net.Client.GrpcChannel 的 ssl 验证部分,它实际上声明它在异常消息传递中使用了 HttpClient。

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.");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Cloud Vision API-创建Grpc.Core.Channel时出错 - Google Cloud Vision API - Error creating Grpc.Core.Channel Grpc.Core 更新到 2.23,System.MissingMethodException: Method not found: Void Grpc.Core.ClientBase`1..ctor(Grpc.Core.Channel) - Grpc.Core updated to 2.23, System.MissingMethodException: Method not found: Void Grpc.Core.ClientBase`1..ctor(Grpc.Core.Channel) gRPC 和 ASP Net Core:GrpcChannel 不支持使用带有非空参数的 SslCredentials - gRPC and ASP Net Core: using SslCredentials with non-null arguments is not supported by GrpcChannel 在 Net Core 3.0 中同时使用 GRPC 通道 - An using GRPC Channel concurrently in Net Core 3.0 grpc 和 polly - .net 核心 6 - grpc and polly - .net core 6 .NET Core:如何为服务和客户端之间的 gRpc 通信禁用 TLS/SSL? - .NET Core: How to disable TLS/SSL for gRpc communication between service and client? 我可以针对 .net CORE gRPC 服务器使用 .NET 框架 gRPC 客户端吗? - Can i use a .NET Framework gRPC Client against a .net CORE gRPC Server? .net 核心 Grpc 客户端无法调用 Greeter 服务 - .net Core Grpc Client unable to call Greeter Service 具有未加密 HTTP2 连接的 .Net Core 3.1 gRPC 客户端 - .Net Core 3.1 gRPC client with unencrypted HTTP2 connection 使用 ASP.NET 核心 DI 容器注册“类型化”gRPC 客户端 - Registering a “typed” gRPC client with the ASP.NET Core DI container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM