# Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="连接到所有地址失败；最后错误：UNKNOWN：连接重置")

- **ID:** `dotnet/grpc-unavailable-connection-reset`
- **领域:** dotnet
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

gRPC 客户端无法建立或维持与服务器的连接，通常由服务器不可用、网络问题或 TLS 配置不匹配引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| dotnet 6.0 | active | — | — |
| dotnet 8.0 | active | — | — |
| Grpc.Core 2.46 | active | — | — |
| Grpc.Net.Client 2.60 | active | — | — |

## 解决方案

1. ```
   Verify server health and network connectivity. Use tools like grpcurl to test the endpoint. Example: grpcurl -insecure <server>:<port> list.
   ```
2. ```
   Ensure TLS certificates are valid and trusted. If using self-signed certs in dev, set GrpcChannelOptions.HttpHandler to bypass validation.
   ```
3. ```
   Check firewall and load balancer settings to ensure gRPC port (usually 5001) is open and HTTP/2 is supported.
   ```

## 无效尝试

- **** — gRPC requires secure connections in production; disabling TLS can cause security warnings or failures if server enforces HTTPS. (80% 失败率)
- **** — Retries will continue to fail if the server is down or firewall blocks the port. (90% 失败率)
- **** — Does not fix the connection issue; just delays the timeout error. (70% 失败率)
