golang: grpc: received message larger than max

rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5533721 vs. 4194304)

意思就是接收信息大小大于设置了, 

客户端报错

// 增加调用选项 grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(recvSize)))
grpc.Dial(host, grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(recvSize)))

服务端报错

// 其实也一样, 设置一下发送 接收的大小
var options = []grpc.ServerOption{
        grpc.MaxRecvMsgSize(recvSize),
        grpc.MaxSendMsgSize(sendSize),
    }
s := grpc.NewServer(options...)

猜你喜欢

转载自blog.csdn.net/halo_hsuh/article/details/107603923