首页 > 解决方案 > 增加 GRPC 消息大小不起作用

问题描述

我正在发送超过 40 MB 的 grpc 消息,我在客户端和服务器端都设置了 grpc 消息大小的限制,如下所示以占用 64 MB 仍然收到大小限制错误?

客户

options = [('grpc.max_send_message_length', 64*1024*1024),
                       ('grpc.max_receive_message_length', 64*1024*1024)]
channel = grpc.secure_channel(channel_endpoint, grpc.ssl_channel_credentials(), options)

服务器

choptions = [('grpc.max_send_message_length', 64*1024*1024),
                ('grpc.max_receive_message_length', 64*1024*1024)]
server = grpc.server(futures.ThreadPoolExecutor(max_workers=max_workers), options=choptions)

遇到错误:

status = StatusCode.RESOURCE_EXHAUSTED
details = "grpc: received message larger than max (4718167 vs. 4194304)

如何解决这个问题?

标签: python-3.xgrpcgrpc-python

解决方案


从错误消息来看,它看起来来自 Go 服务器而不是 Python 服务器https://github.com/grpc/grpc-go/blob/670c133e568e89c901d05b898af9f5ce72a88c6d/rpc_util.go#L573而不是来自 Python 服务器的错误这将 - https://github.com/grpc/grpc/blob/6b916984a8b167d4bcf9c15e21090be49976ceaa/src/core/ext/filters/message_size/message_size_filter.cc#L206

要解决此问题,您还需要提高 Go 服务器的限制。


推荐阅读