# rpc 错误：代码 = ResourceExhausted 描述 = grpc：接收消息大于最大值（5242880 vs. 4194304）

- **ID:** `go/grpc-message-too-large`
- **领域:** go
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

客户端或服务器默认最大消息大小（4MB）被有效载荷超过。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.2 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   opts := []grpc.DialOption{grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(10*1024*1024))}; conn, _ := grpc.Dial("addr", opts...)
   ```
2. **** (80% 成功率)
   ```
   Implement a bidirectional stream to send data in chunks.
   ```

## 无效尝试

- **** — Memory is not the bottleneck; the gRPC framework has hard-coded limits. (95% 失败率)
- **** — Compression not enabled on both sides, and gRPC may not auto-decompress. (60% 失败率)
