# rpc 错误：code = Unavailable desc = 从服务器读取错误：EOF

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

## 根因

服务器在流传输中途关闭了 HTTP/2 连接。通常是服务器进程退出、重启，或代理/负载均衡器断开了连接。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| grpc-go 1.58+ | active | — | — |

## 解决方案

1. **** (85% 成功率)
   ```
   Enable client keepalive to detect dead connections quickly:
conn, err := grpc.NewClient(addr,
    grpc.WithKeepaliveParams(keepalive.ClientParameters{
        Time: 10 * time.Second, Timeout: 3 * time.Second, PermitWithoutStream: true,
    }),
)
   ```
2. **** (82% 成功率)
   ```
   Add a retry policy for UNAVAILABLE and inspect server logs for crashes:
// configure retryableStatusCodes: ["UNAVAILABLE"] in the service config, then check server OOM/panic logs.
   ```

## 无效尝试

- **** — The error originates at the transport layer from the server side closing the connection; the client handler is not at fault. (70% 失败率)
- **** — Disabling keepalive does not prevent the server from closing; it actually makes stale connections harder to detect. (80% 失败率)
