grpc : Received message larger than max

status = StatusCode.RESOURCE_EXHAUSTED
        details = "Received message larger than max (4282239 vs. 4194304)"
        debug_error_string = "{"created":"@1633745838.187727309","description":"Received message larger than max (4282239 vs. 4194304)"

grpc 默认的传输长度是4M,当超过4M时会出现上面的错误。需要定制传输参数。

从server端和client端都需要指定传输参数如下:

在server端 设置 server参数:

MAX_MESSAGE_LENGTH = 256*1024*1024  # 可根据具体需求设置,此处设为256M



server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), options=[
                             ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
                             ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH),
                         ]
                         # compression=grpc.Compression.Gzip,
                         # interceptors=...,
                         )

在client端设置channel参数:

MAX_MESSAGE_LENGTH = 256*1024*1024  # 可根据具体需求设置,此处设为256M



with grpc.insecure_channel(target=docker_channel, options=[
                             ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
                             ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH),
                         ]
                         # compression=grpc.Compression.Gzip,
                          ) as channel:

如果开发语言采用的是C++, 可参考 

python grpc报错Received message larger than max_liyangbinbin的博客-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值