duanjiao8007 2018-10-25 15:39 采纳率: 100%
浏览 2380
已采纳

gRPC设置问题。 出现间歇性RPC不可用错误

我有一个grpc服务器和客户端,大部分时间都能正常运行,但是偶尔会收到“传输正在关闭”错误:

rpc error: code = Unavailable desc = transport is closing

我想知道我的设置是否有问题。 客户端很基础

connection, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
pb.NewAppClient(connection)
defer connection.Close()

并以类似超时的方式拨打电话

ctx, cancel := context.WithTimeout(ctx, 300*time.Millisecond)
defer cancel()

client.MyGRPCMethod(ctx, params)

我正在做的另一件事是检查连接来查看它是处于打开,空闲还是正在连接状态,如果有则重新使用该连接。 否则,请重拨。 p>

服务器没有任何特殊配置

grpc.NewServer()

设置grpc客户端/服务器时是否会遇到一些常见错误?

  • 写回答

3条回答 默认 最新

  • douwen0647 2018-10-31 20:33
    关注

    One other thing I'm doing is checking the connection to see if it's either open, idle or connecting, and reusing the connection if so. Otherwise, redialing.

    grpc will manage your connections for you, reconnecting when needed, so you should never need to monitor it after creating it unless you have very specific needs.

    "transport is closing" has many different reasons for happening; please see the relevant question in our FAQ and let us know if you still have questions: https://github.com/grpc/grpc-go#the-rpc-failed-with-error-code--unavailable-desc--transport-is-closing

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题