# rpc 错误：代码 = ResourceExhausted 描述 = grpc：接收到的消息大于最大值（5242889 对比 4194304）

- **ID:** `go/grpc-resource-exhausted-receive-buffer`
- **领域:** go
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

gRPC 消息大小超过默认最大值 4 MB（4194304 字节）。服务器或客户端未调整最大接收消息大小。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*10)) on client; grpc.MaxRecvMsgSize(1024*1024*10) in server options.
   ```
2. **** (80% 成功率)
   ```
   Implement a custom streaming or pagination mechanism.
   ```

## 无效尝试

- **** — Compression may not always be possible or sufficient; the underlying data may still exceed limits after compression. (50% 失败率)
- **** — The message size will not change, so the error will recur. (95% 失败率)
