【发布时间】:2019-09-30 08:01:45
【问题描述】:
我正在学习rpc&grpc,现在去,我被grpc弄糊涂了。
在学习GitHub(https://github.com/grpc/grpc-go/tree/master/examples)上的例子时,遇到了一些问题。在服务器中,我使用address = "ip:50051" 而不是address = ":50051"(ip 是我的内网IP),在客户端我使用address = "ip:50051" 而不是address= "localhost:50051",然后运行服务器和客户端,在客户端我得到错误:
rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing failed to do connect handshake, response: \"HTTP/1.0 504 Gateway Time-out\\r\\nConnection: close
但是当我在golang中学习rpc的时候,在服务器和客户端使用我的内网ip就可以了。
所以我想知道为什么 grpc 出错了?
【问题讨论】:
-
试试
0.0.0.0:50051,它将在端口 50051 上侦听所有接口,这通常是您想要的 -
@RobbieMilejczak ths,我在服务器中尝试
0.0.0.0:50051,但它不行。我在客户端使用myInetIp:50051,也得到与上面相同的错误。