WCF服务超时 - 服务需要几分钟才能响应简单请求

时间:2017-06-16 21:51:36

标签: performance wcf wcf-binding

我们有一个简单的服务配置:

<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>

在我将附加参数添加到绑定名称=&#34; defaultBinding&#34;之前,服务已超时。 (closeTimeout,openTimeout,receiveTimeout,sendTimeout,maxbuffersize,maxreceivedmessagesize)。

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

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

是否存在我不知道的网络配置设置,或者这是否归结为服务器计算机或可能是IIS?

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

1 个答案:

答案 0 :(得分:1)

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

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

故事的道德:仔细检查你的功能 - 即使它们看起来很简单,也可能会在引擎盖下做其他一些事情:)

相关问题