本文介绍了gRPC Python-如何为客户端添加空闲时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用gRPC在客户端中调用服务.设置频道后:
I'm using gRPC to call a service in client. After I set up channel:
channel = grpc.insecure_channel('server_url:service_port')
stub = Client.Stub(channel)
效果很好.但是,如果有5分钟未使用客户端发送请求,则下一个请求将收到错误消息:
It works pretty good. However, if there's 5 minutes not using the client to send request, then the next request will get error message:
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Stream removed)>
推荐答案
不幸的是,当频道中断时,gRPC重试功能仍在进行中,尚不完全可用.作为解决方法,您可以做的一件事是编写一个拦截器,以在遇到此类错误时自动重试.
Unfortunately the gRPC retries functionality when the channel breaks is still work in progress and not fully available yet. One thing you could do as a workaround is to write an interceptor to retry automatically if it sees such error.
这篇关于gRPC Python-如何为客户端添加空闲时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!