没有加密或身份验证的grpc(InsecureChannel)是否在2个远程服务器之间工作

时间:2019-08-13 12:12:57

标签: grpc grpc-python

我有一个grpc客户端和运行在2个不同服务器中的服务器。使用此设置,当我运行客户端时,出现以下错误。

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();

0 个答案:

没有答案