# rpc 错误：代码 = DeadlineExceeded 描述 = 上下文截止时间已超过

- **ID:** `go/grpc-deadline-exceeded`
- **领域:** go
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

RPC 调用耗时超过客户端设置的上下文截止时间。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second); defer cancel()
   ```
2. **** (70% 成功率)
   ```
   Profile and optimize the RPC handler to reduce latency.
   ```

## 无效尝试

- **** — Server timeout doesn't affect client-side context deadlines. (70% 失败率)
- **** — gRPC requires deadlines; disabling can lead to hanging calls. (80% 失败率)
