目前我正在使用下面的代码来启动 grpc 服务器,我想以这种方式启动图形服务器和客户端,以便我能够在不同的机器上运行它们,然后连接它们。
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
xyz_pb2_grpc.add_xyzServicer_to_server(
xyzServicer(), server
)
server.add_insecure_port("localhost:50051")
server.start()
print("server started")
server.wait_for_termination()
我使用上述方法在同一台机器上连接服务器和客户端,但现在我想在不同机器上连接服务器和客户端
正如@rasjani所说,对于ipV6使用
0.0.0.0:50051
或ipV4或[::]:50051
。您可以在https://grpc.io/docs/languages/python/basics/#starting-the-server查看基本教程