dotnet network_error ai_generated true

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

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="failed to connect to all addresses; last error: UNKNOWN: Connection reset")

ID: dotnet/grpc-unavailable-connection-reset

其他格式: JSON · Markdown 中文 · English
82%修复率
85%置信度
1证据数
2023-03-10首次发现

版本兼容性

版本状态引入弃用备注
dotnet 6.0 active
dotnet 8.0 active
Grpc.Core 2.46 active
Grpc.Net.Client 2.60 active

根因分析

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

English

gRPC client cannot establish or maintain a connection to the server, often due to server unavailability, network issues, or TLS configuration mismatches.

generic

官方文档

https://learn.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-8.0#connection-reset

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 80% 失败

    gRPC requires secure connections in production; disabling TLS can cause security warnings or failures if server enforces HTTPS.

  2. 90% 失败

    Retries will continue to fail if the server is down or firewall blocks the port.

  3. 70% 失败

    Does not fix the connection issue; just delays the timeout error.