我有一个运行在 2 个不同服务器上的 grpc 客户端和服务器。使用此设置,当我运行客户端时,将出现以下错误。
Connect failed: {"created":"@1565697395.391945051","description":"Failed to connect to remote host: FD
Shutdown","file":"src/core/lib/iomgr/lockfree_event.cc","file_line":194,"os_error":"Timeout occurred","referenced_errors":
[{"created":"@1565697395.391908468","description":"connect() timed out","file":"src/core/lib/iomgr/tcp_client_posix.cc","file_line":119}],"target_address":"ipv4:192.168.1.14:50051"}
如果客户端和服务器在同一台服务器上,它工作正常。
client code(python)
---------------------
channel = grpc.insecure_channel('192.168.1.14:50051')
stub = mmeGrpc_pb2_grpc.MmeGrpcCliStub(channel)
server code(cpp)(192.168.1.14)
----------------
std::string server_address("0.0.0.0:50051");
MmeGrpcCliServiceImpl service;
ServerBuilder builder;
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart());
server->Wait();