[英]Grpc client on Net 6 doesn't connect with grpc server on Net 4.8
當客戶端和服務器在同一台電腦上工作時,它們連接正常。
下一種情況是真實 pc 上的服務器,VirtualBox 上的客戶端。 兩個設備都有 Windows 10. 服務器上的防火牆被禁用。 當客戶端嘗試 co.net 到服務器異常時發生:
Grpc.Core.RpcException: 'Status(StatusCode="Internal", Detail="啟動 gRPC 調用時出錯。
客戶端代碼:
public ThermocyclerClient()
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
var httpClient = new HttpClient(httpClientHandler);
var channel = GrpcChannel.ForAddress("http://192.168.111.189:7001", new GrpcChannelOptions { HttpClient = httpClient });
client = new ThermocyclerRpcService.ThermocyclerRpcServiceClient(channel);
}
服務器代碼:
server = new Server
{
Ports = { new ServerPort("localhost", 7001, ServerCredentials.Insecure) },
Services =
{
ExtractorRpcService.BindService(this.extractorService),
ThermocyclerRpcService.BindService(this.thermocyclerService)
}
};
為什么客戶端無法連接到服務器?
Real pc 和 VirtualBox 都成功地 ping 通了。
Marc Gravell 在評論中給出了正確答案。 從本地主機更改為計算機名稱有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.