100次通话后,WCF服务停止工作

时间:2017-03-16 11:02:37

标签: c# .net wcf service connection

使用我的WCF服务时遇到问题。我在控制台应用程序中使用了我的WCF服务,它可以正常工作直到100个请求(循环中)。但它在100次请求后停止工作。我已经用过了

<serviceThrottling
                    maxConcurrentCalls="500"
                    maxConcurrentInstances="500"
                    maxConcurrentSessions="500"/>

在我的配置中,但它对此问题没有影响。我在每次调用服务后都关闭了连接,但问题仍然存在。

非常感谢任何帮助。

下面是我的web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>


  <connectionStrings>

    <add name="PriceGain" connectionString="Server=xyz.abc.com;Database=SomeDB;User Id=appuser;password=xxxxxxx;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="AirGainUtilities.Service.Utilities" behaviorConfiguration="UtilitiesBehavior">
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
         <endpoint address="http://192.168.1.1/AirGain.Utilities.Service/Utilities.svc" binding="basicHttpBinding" contract="AirGainUtilities.Service.IUtilities" /> 
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00"
          sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="UtilitiesBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" 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" />

          <serviceThrottling
                    maxConcurrentCalls="5000"
                    maxConcurrentInstances="5000"
                    maxConcurrentSessions="5000"/>
        </behavior>

      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
       <add binding="basicHttpBinding" scheme="http" /> 
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <add value="Utilities.svc" />
            </files>
        </defaultDocument>
  </system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:0)

显然,问题是Package Class中的GetDestinationHotelId方法中的打开数据库连接。由于异常并且在达到100个打开的连接 MAX CONNECTION POOL LIMIT 之后,DB连接未关闭。

我真的很傻: - (