超过 2 分钟的 gRPC 流调用被客户端和服务器之间的硬件(路由器等)终止

gRPC streaming call which takes longer than 2 minutes is killed by hardware (routers, etc.) in between client and server

Grpc.Net 客户:

解决方案:

代码被截断:

SocketsHttpHandler socketsHttpHandler = new SocketsHttpHandler()
{
    PooledConnectionIdleTimeout = TimeSpan.FromMinutes(180),
    PooledConnectionLifetime = TimeSpan.FromMinutes(180),
    KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always,
    KeepAlivePingTimeout = TimeSpan.FromSeconds(90),
    KeepAlivePingDelay = TimeSpan.FromSeconds(90)
};

socketsHttpHandler.SslOptions.RemoteCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };

HttpClient httpClient = new HttpClient(socketsHttpHandler);
httpClient.Timeout = TimeSpan.FromMinutes(180);

var channel = GrpcChannel.ForAddress(_agentServerURL, new GrpcChannelOptions
{
    Credentials = ChannelCredentials.Create(new SslCredentials(), credentials),
    MaxReceiveMessageSize = null,
    MaxSendMessageSize = null,
    MaxRetryAttempts = null,
    MaxRetryBufferPerCallSize = null,
    MaxRetryBufferSize = null,
    HttpClient = httpClient
});

这就是我需要的。这个问题我几个月了,但我唯一的解决办法是减少数据量。