简体   繁体   English

C#:超时与经过的时间不匹配

[英]C#: Timeout does not match elapsed time

I have an application that connects to a service (webserviceSoap1), and that service has the next timeout configuration: 我有一个连接到服务(webserviceSoap1)的应用程序,并且该服务具有下一个超时配置:

<binding name="webserviceSoap1" 
         openTimeout="00:10:00" 
         closeTimeout="00:10:00" 
         sendTimeout="00:10:00"
         receiveTimeout="00:10:00">

From what I understand, I'm stating here that all timeouts have to wait at least 10 minutes to end communication and get a System.TimeoutException . 据我了解,我在这里说的是所有超时都必须等待至少10分钟才能结束通信并获取System.TimeoutException However, here is the issue I'm not understanding . 但是, 这是我不了解的问题 After around 2-3 minutes, i get a TimeoutException saying that the program waited for a response almost ten minutes (which is not possible), and in the same place, it says the elapsed time was around two minutes 大约2-3分钟后,我收到一个TimeoutException消息,该程序等待响应将近十分钟(这是不可能的),并且在同一位置,它说经过的时间约为两分钟

超时异常表明它等待了将近10分钟,但经过的时间约为2分钟

Why the gap of time? 为什么间隔时间? Am I configuring the binding values correctly? 我是否正确配置绑定值?

If I change the values of the timeouts to "10:00:00" it will complete the process correctly. 如果我将超时值更改为“ 10:00:00”,它将正确完成此过程。 However, still using "01:00:00", which I understand is an hour, the process breaks after 4 minutes saying that it waited "00:59:59.16472" before sending the TimeoutException. 但是,仍然使用“ 01:00:00”(据我所知是一个小时),该过程在4分钟后中断,说它在发送TimeoutException之前等待了“ 00:59:59.16472”。

The problem was located within the Load Balancer that was managing the connection of the client to the server. 该问题位于负载均衡器中,该负载均衡器正在管理客户端到服务器的连接。 Both the client and the service were configured to wait 10 minutes of timeout. 客户端和服务都配置为等待10分钟的超时。 However, the Load Balancer had only one minute, and that's why the timeout was arising sooner than expected. 但是,负载均衡器只有一分钟,这就是为什么超时比预期的要早的原因。

I ask the administrators of the Load Balancer to change it to 10 minutes and everything is working as expected. 我要求负载均衡器的管理员将其更改为10分钟,并且一切正常。

However, the way the timeout is reported to the client is very misleading, since it states that the set timeout has already reached to the limit, when this is not true. 但是,将超时报告给客户端的方式非常容易引起误解,因为它指出设置的超时已经达到极限(如果不正确)。

Also, the way the Load Balancer manages the interruption of the service can be misleading, since in my case, the Load Balancer (F5) would wait until the service returns a response, and then, it would interrupt the response, arising its own timeout error. 同样,负载平衡器管理服务中断的方式可能会误导,因为在我的情况下,负载平衡器(F5)将等待直到服务返回响应,然后中断响应,导致自身超时错误。 As a result, the client only receives the notice of the reached timeout. 结果,客户端仅收到到达超时的通知。 Also, the client will not get this error in one minute (set by the load balancer), nor in 10 minutes (set by the service), but at the time the service returns the response. 此外,客户端不会在一分钟内(由负载均衡器设置),也不会在十分钟内(由服务设置),但在服务返回响应时,将收到此错误。

I hope this helps to anyone getting a similar behavior. 我希望这对任何获得类似行为的人都有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM