grpc 状态代码不可用,详细信息为 OS 错误

grpc status code UNAVAILABLE and details as OS error

出现间歇性错误,仅当使用 docker 堆栈部署启动容器时,使用 docker-compose 工作正常 ` grpc._channel._Rendezvous: <_RPC 的集合点终止于: 状态 = StatusCode.UNAVAILABLE 详细信息 = "OS Error" debug_error_string = "{"created":"@1565004909.399609656", "description":"Error received from peer", "file":"src/core/lib/surface/call.cc", "file_line":1036, "grpc_message":"OS Error", "grpc_status":14}"

channel = implementations.insecure_channel(host, int(port))
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)
request = predict_pb2.PredictRequest()
result = stub.Predict(request, 100.0)`

在解决方案中,有效的是添加重试逻辑, 捕获 grpc 错误并再次调用 stub.Predict

try:
        result = stub.Predict(request, 100.0)  # 100 seconds
    except grpc.RpcError as e:
        result = stub.Predict(request, 100.0)  # 100 seconds