2017-06-16 137 views
0

我们已经配置为这样一个简单的服务响应:WCF服务超时 - 服务需要几分钟到简单的请求

<configuration> 
    <connectionStrings> 
    <add name="CONN" connectionString="Server=MYSERVER,1433;Database=mydb;User Id=user;Password=pass;"/> 
    </connectionStrings> 
    <system.web> 
    <customErrors mode="Off"/> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     </assemblies> 
    </compilation> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="MyNamespace.MyService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://mywebsite.com/TestService/"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="basicHttpBinding" contract="MyNameSpace.IMyService" bindingConfiguration="defaultBinding" bindingNamespace="MyNameSpace"/> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="defaultBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" 
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None"/> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

这项服务是在超时之前我添加了额外的参数绑定名称=“defaultBinding “(closeTimeout,openTimeout,receiveTimeout,sendTimeout,maxbuffersize,maxreceivedmessagesize)。

我们的服务器只启用了TLS1.2。 该服务托管在IIS中,证书似乎没问题 - 浏览网页中的WSDL看起来没问题。

在同一台机器的机器上使用SOAPUI作为服务托管超时(我认为这将是非常快?)

是否有web配置设置,我不知道,或者这是否归结为服务器机器或可能的IIS?

请求可能需要几分钟才能完成 - 即使是像GetVersion()调用那样简单的返回字符串也是如此。我们甚至重新启动了机器,IIS等,并尝试了新的请求 - 同样的问题。

+1

像往常一样,所有的WCF时序问题下做一些其他的东西 - 从WCF启用详细的日志,并检查其中时间花在:https://docs.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/configuring-message-logging –

+0

谢谢你的资源@IgorLabutin我会考虑这样做,并会回来任何我找到的。 –

+0

我看着它@IgorLabutin并在下面发布我的答案。花费了时间来处理请求消息,导致连接超时。谢谢。 –

回答

1

原来我的GetVersion()调用实际上有一个LogActivity()调用会记录到数据库。 web.config中的连接字符串不正确,导致数据库连接旋转,直到数据库连接超时。数据库连接超时设置为高于服务/客户端的超时,因此客户端在发生数据库超时之前会超时。由于不需要为我们记录失败的日志记录,因此数据库连接超时将静默地发生。

修复连接字符串使服务迅速响应。

这个故事的寓意:仔细检查您的功能 - 即使他们看起来似乎很简单,他们可能引擎盖:)