# 已取消：服务器关闭导致流关闭

- **ID:** `grpc/stream-interrupted-by-shutdown`
- **领域:** grpc
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器正在正常关闭，导致所有活跃流被关闭。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| gRPC Python 1.46.0 | active | — | — |
| gRPC Go 1.50.0 | active | — | — |

## 解决方案

1. ```
   Implement client-side reconnection logic with exponential backoff. Example in Python: `channel = grpc.insecure_channel('target', options=[('grpc.service_config', '{"methodConfig": [{"name": [{}], "retryPolicy": {"maxAttempts": 5, "initialBackoff": "0.1s", "maxBackoff": "1s", "backoffMultiplier": 2, "retryableStatusCodes": ["UNAVAILABLE"]}}]}')])`
   ```
2. ```
   Use a load balancer to route requests to healthy server instances.
   ```

## 无效尝试

- **** — The server is down; retries will fail until the server is back. (80% 失败率)
- **** — Keepalive settings do not prevent server shutdown from closing streams. (60% 失败率)
- **** — The stream is permanently closed; a new stream must be created. (95% 失败率)
