来自 Python 服务器的 gRPC 一元流 -> C# 客户端:"Stream removed"
gRPC Unary Stream from Python server -> C# Client: "Stream removed"
我有一个从 Python 服务器 (1.8.4) 到 C# 客户端 (1.8.3) 的一元流服务。
当我向 Python 发出关闭信号(第 15 学期)时,将调用下面代码清单中的 shutdown
方法,其目的是正常终止 RPC,并关闭服务器.
这在我 运行 本地主机上的服务器时有效,引发了具有预期状态的 RpcException:Status(StatusCode=Cancelled, Detail="Completed")
但是,当 运行 Kubernetes (GKE) 中的服务器并终止我收到的 pod 时:Grpc.Core.RpcException: Status(StatusCode=Unknown, Detail="Stream removed")
在客户端。 python 服务器在 haproxy 入口控制器和 google-cloud-endpoint 代理后面,但据我所知,这些组件都不应该影响连接。
有人能想到是什么导致了客户端 RpcException 中的不同状态吗?
class StreamsService(StreamsServicer):
def MyHandler(self, request, context):
while not stop_event.isSet():
try:
yield update_q.get(True, 0.1)
except queue.Empty:
continue
context.set_code(grpc.StatusCode.CANCELLED)
context.set_details("Completed")
def shutdown(subscriber_service: StreamsService,
executor: futures.ThreadPoolExecutor,
server: grpc.Server, exit_code):
logger.info("Stopping stream handlers")
for stop_event in subscriber_service.stop_events:
stop_event.set()
logger.info("Stopping executor")
executor.shutdown()
logger.info("Stopping server")
ev: threading.Event = server.stop(grace=10) # allows RPCs to terminate gracefully
logger.info("Waiting for server to stop gracefully")
ev.wait()
logger.info("Stopping process with exit code {}".format(exit_code))
sys.exit(exit_code)
(ps。交叉发布自 https://groups.google.com/forum/#!topic/grpc-io/Ge6hcUUhXzo)
原来这个是一个问题,google-cloud-endpoint/NGINX容器在同一个pod中的gRPC服务器容器有机会优雅地关闭它的连接之前被终止。
如果有人有兴趣了解更多信息,我在这里与自己进行了一次对话:https://groups.google.com/forum/#!topic/google-cloud-endpoints/FyfdvD6xS1Q
我有一个从 Python 服务器 (1.8.4) 到 C# 客户端 (1.8.3) 的一元流服务。
当我向 Python 发出关闭信号(第 15 学期)时,将调用下面代码清单中的 shutdown
方法,其目的是正常终止 RPC,并关闭服务器.
这在我 运行 本地主机上的服务器时有效,引发了具有预期状态的 RpcException:Status(StatusCode=Cancelled, Detail="Completed")
但是,当 运行 Kubernetes (GKE) 中的服务器并终止我收到的 pod 时:Grpc.Core.RpcException: Status(StatusCode=Unknown, Detail="Stream removed")
在客户端。 python 服务器在 haproxy 入口控制器和 google-cloud-endpoint 代理后面,但据我所知,这些组件都不应该影响连接。
有人能想到是什么导致了客户端 RpcException 中的不同状态吗?
class StreamsService(StreamsServicer):
def MyHandler(self, request, context):
while not stop_event.isSet():
try:
yield update_q.get(True, 0.1)
except queue.Empty:
continue
context.set_code(grpc.StatusCode.CANCELLED)
context.set_details("Completed")
def shutdown(subscriber_service: StreamsService,
executor: futures.ThreadPoolExecutor,
server: grpc.Server, exit_code):
logger.info("Stopping stream handlers")
for stop_event in subscriber_service.stop_events:
stop_event.set()
logger.info("Stopping executor")
executor.shutdown()
logger.info("Stopping server")
ev: threading.Event = server.stop(grace=10) # allows RPCs to terminate gracefully
logger.info("Waiting for server to stop gracefully")
ev.wait()
logger.info("Stopping process with exit code {}".format(exit_code))
sys.exit(exit_code)
(ps。交叉发布自 https://groups.google.com/forum/#!topic/grpc-io/Ge6hcUUhXzo)
原来这个是一个问题,google-cloud-endpoint/NGINX容器在同一个pod中的gRPC服务器容器有机会优雅地关闭它的连接之前被终止。
如果有人有兴趣了解更多信息,我在这里与自己进行了一次对话:https://groups.google.com/forum/#!topic/google-cloud-endpoints/FyfdvD6xS1Q