grpc默认传输文件大小为4*1024*1024 也就是4兆

grpc 异常 Received message larger than max (5009675 vs. 4194304) 处理



因为grpc默认传输文件大小为410241024 也就是4兆,超出此大小便会抛出StatusCode.RESOURCE_EXHAUSTED这个异常,解决此问题需要修改默认传输大小限制

https://blog.csdn.net/weixin_41935140/article/details/107034206



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),
]
)


Category golang