简体   繁体   English

无法解释的WCF服务超时

[英]Unexplainable WCF Service Timeout

Running an MVC web site that calls a WCF service. 运行一个调用WCF服务的MVC网站。
Site and service on 2 different machines. 在2台不同的机器上的站点和服务。
.NET framework 4; .NET Framework 4; IIS 7. IIS 7。

Production site is encountering a timeout when it should not. 生产站点遇到超时,该超时不该发生。 I created the simplest samples I could (simple web site that calls service method that returns "hi mom" after a delay) and was able to reproduce the problem. 我创建了最简单的示例(一个简单的网站,该网站调用在延迟后返回“ hi mom”的服务方法)并能够重现该问题。 Here is how it goes: 这是怎么回事:

  • Client web app has it's binding's SendTimeout set to 6 minutes. 客户端网络应用将其绑定的SendTimeout设置为6分钟。
  • Server service does nothing but write a message to a file, sleep for 5 minutes, write another message. 服务器服务除了将一条消息写入文件外,什么都不做,请休眠5分钟,再写入另一条消息。
  • Messages written to file on server are correct; 写入服务器上文件的消息是正确的; server trace shows no problems. 服务器跟踪显示没有问题。
  • Client never receives return value from server service method. 客户端从不从服务器服务方法接收返回值。 It's like it just loses it's connection to the server. 就像失去了与服务器的连接一样。
  • Client throws TimeoutException after 6 minutes (any timeout greater than that just delays the exception further). 客户端在6分钟后抛出TimeoutException(任何超时都将进一步延迟该异常)。 If I change the thread sleep time on the server to 4 minutes, everything works fine. 如果我将服务器上的线程睡眠时间更改为4分钟,则一切正常。 This is repeatable, and there is nobody else messing with this test scenario. 这是可重复的,并且没有其他人对此测试方案感到困惑。

So here is the pertinent config section of the client: 因此,这是客户端的相关配置部分:

    <binding name="BasicHttpBinding_IService1"
             closeTimeout="00:6:00"
             openTimeout="00:6:00"
             receiveTimeout="00:6:00"
             sendTimeout="00:6:00"
             allowCookies="false"
             bypassProxyOnLocal="false"
             hostNameComparisonMode="StrongWildcard"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647"
             maxReceivedMessageSize="2147483647"
             messageEncoding="Text"
             textEncoding="utf-8"
             transferMode="Buffered"
             useDefaultWebProxy="true">

<httpRuntime executionTimeout="1200"
             maxRequestLength="10240" />

  <serviceBehaviors>
    <behavior>
      <serviceTimeouts transactionTimeout="00:6:00" />
    </behavior>
  </serviceBehaviors>

The same values are present on the server. 服务器上存在相同的值。 Following include things I've tried: 以下包括我尝试过的事情:

  • Added the serviceTimeouts element above. 在上面添加了serviceTimeouts元素。
  • Ensured to call close on the client proxy class (even though that wouldn't be the issue in my case since the error happens every time). 确保在客户端代理类上调用close(即使在我看来,这也不是问题,因为每次都会发生错误)。
  • Created a channel explicitly, cast as IContextChannel and set OperationTimeout (as outlined here ). 创建一个渠道明确,铸成IContextChannel并设置OperationTimeout(所概述这里 )。
  • Increased the FailureInterval property of the server's app pool in IIS. 增加了IIS中服务器应用程序池的FailureInterval属性。
  • Ensured that all the timeout values of the binding element in the configs were all set to a value greater than the time taken by the service method. 确保将配置中绑定元素的所有超时值都设置为大于service方法花费的时间的值。
  • Created a ChannelFactory and set it's Endpoint.Binding.SendTimeout value. 创建一个ChannelFactory并将其设置为Endpoint.Binding.SendTimeout值。
  • Ensured that Compilation debug="false" was set at client and server (read that timeouts [unsure which timeouts] not respected correctly unless this is set). 确保在客户端和服务器上设置了编译debug =“ false”(除非设置了该超时,否则请阅读该超时[不确定哪些超时])。
  • Increased maxBufferSize, maxBufferPoolSize, and maxReceivedMessageSize even though this shouldn't have anything to do with the problem (the server simply returns "hi mom"). 增加了maxBufferSize,maxBufferPoolSize和maxReceivedMessageSize,即使这与问题无关(服务器仅返回“ hi mom”)。
  • Set SendTimeout explicitly in code on the client proxy (since this should be the relevant timeout). 在客户端代理上的代码中显式设置SendTimeout(因为这应该是相关的超时)。
  • Called the service from a console app (same result). 从控制台应用程序调用了该服务(结果相同)。

What else can I try? 我还能尝试什么?

[Edit] Moved the service to the same machine as the web app and the problem goes away. [编辑]将服务移至与Web应用程序相同的机器上,问题消失了。

这是生产环境中防火墙上的HTTP策略:最长请求时间为5分钟。

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

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