Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure在5m时超时连接,是否使用保持活动?_C#_Timeout_Keep Alive - Fatal编程技术网

C# Azure在5m时超时连接,是否使用保持活动?

C# Azure在5m时超时连接,是否使用保持活动?,c#,timeout,keep-alive,C#,Timeout,Keep Alive,我正在调试一个中间层服务,它偶尔会向第三方服务发出长时间运行的请求(约1500万个),以调用客户端 只要请求时间超过5m,调用方/客户端就会出现以下异常: System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unab

我正在调试一个中间层服务,它偶尔会向第三方服务发出长时间运行的请求(约1500万个),以调用客户端

只要请求时间超过5m,调用方/客户端就会出现以下异常:

System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host ...
客户端正在将其超时和读写超时设置为15m。研究表明,我需要使用TCP保持活动状态,以便在请求期间保持客户端和中间层服务之间的连接处于打开状态

我想开始使用:

var httpRequest = WebRequest.CreateHttp(new Uri("https://someendpoint"));
httpRequest.ServicePoint.SetTcpKeepAlive(true, 120 * 1000, 120 * 1000);
我担心的是,我已经在使用以下方法通过DNS强制执行负载平衡更改,我不知道这两者是如何相互作用的:

httpRequest.ServicePoint.ConnectionLeaseTimeout = 30 * 1000;
我想确保
SetTcpKeepAlive
的引入不会影响大约每30秒打开一个新
ServicePoint
的预期行为。我知道长时间运行的请求在完成之前仍将绑定到旧的
ServicePoint
对象,但我希望确保:

  • 大约每30秒,新的请求就会发送给新的
    ServicePoint
    ,以防故障切换/DNS更改
  • 长期运行 请求能够使用keep-alive来保持中间层服务 防止由于等待时连接处于空闲状态而断开连接 要响应的第三方服务