简体   繁体   English

gRPC C++ 错误代码 14:无法连接到所有地址

[英]gRPC C++ Error code 14 : failed to connect to all addresses

I am trying to implement gRPC server/ client for the first time using Windows Subsystem for Linux kernel and CLion as the IDE (on Windows).我第一次尝试使用适用于 Linux 内核的 Windows 子系统和 CLion 作为 IDE(在 Windows 上)实现 gRPC 服务器/客户端。 My code does not have any other bugs/ issues except this communication failure.除了此通信失败之外,我的代码没有任何其他错误/问题。

The following lines of code以下代码行

    if(status.ok()) {
        cv::imshow("Rotated image", decrypt_img);
    } else {
        std::cout << status.error_code() << " : " << status.error_message() << std::endl;
    }

yields the following message产生以下消息

14 : failed to connect to all addresses

This is a kind of generic error message from grpc which can have multiple causes.这是来自 grpc 的一种通用错误消息,可能有多种原因。 In my experience, it can be one of the following things:根据我的经验,它可能是以下情况之一:

  1. Your server isn't running (either you forgot to call grpc::ServerBuilder::BuildAndStart or you didn't start your server application all along).您的服务器没有运行(您忘记调用grpc::ServerBuilder::BuildAndStart或者您一直没有启动服务器应用程序)。
  2. When running the server for the first time Windows Firewall should ask you if you want to allow your application to access the network (I don't recall the actual wording).当第一次运行服务器时,Windows 防火墙应该询问您是否允许您的应用程序访问网络(我不记得实际的措辞)。 You want to accept this, of course.你当然想接受这一点。
  3. You have a wrong address specified in your client application (ie a different one than you have set in your server application via grpc::ServerBuilder::AddListeningPort )您在客户端应用程序中指定了错误的地址(即与您在服务器应用程序中通过grpc::ServerBuilder::AddListeningPort设置的地址不同)

Not knowing your actual server and client code these are just assumptions I can make based on my experience with grpc.不知道您的实际服务器和客户端代码,这些只是我可以根据我对 grpc 的经验做出的假设。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM