python grpc StatusCode.RESOURCE_EXHAUSTED,Received message larger than max (6085801 vs. 4194304)

异常原因:

grpc默认消息体大小是4M,大于4M则会抛出该异常

解决方案:

在客户端和服务端自定义最大消息体大小

客户端:

grpc.insecure_channel(grpc_url, 
                        options=[('grpc.max_send_message_length', MAX_MESSAGE_LENGTH), 
                                'grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)])

服务端

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

你可能感兴趣的:(异常记录,python,服务器)