C# WCF服务在100次呼叫后停止工作

C# WCF服务在100次呼叫后停止工作,c#,.net,wcf,service,connection,C#,.net,Wcf,Service,Connection,我在使用WCF服务时遇到了一个问题。我在一个控制台应用程序中使用了我的WCF服务,它可以正常工作到100个请求(在一个循环中)。但它在收到100个请求后停止工作。我已经用过了 <serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="500" maxConcurrentSessions="500

我在使用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>

显然,问题是Package类的GetDestinationHotelId方法中存在一个开放数据库连接。由于异常,DB连接未关闭,并且在100个打开的连接达到最大连接池限制后


真的很傻:(

当你启用FaultExceptions时,你会得到什么错误?嗨,Shuto,事实上,我也没有得到任何异常我是WCF的新手,可能是我做错了什么:public List GetDestinationHotelId(string DestinationAirport){试试看{Package objPkg=new Package();返回objPkg.GetDestinationHotelId(DestinationAirport);}catch(异常fe){抛出新的FaultException(fe.Message);}//返回null;}上面是我的服务契约方法。下面是使用它的客户端应用程序代码:int x=0;而(true){x++;使用(AirGainUtilities.Service.UtilitiesClient UC=new AirGainUtilities.Service.UtilitiesClient()){List lstHotels=UC.GetDestinationHotelId(“SJD”);如果(lstHotels.Count请编辑您的问题并添加客户端代码。哦,我发现了问题…它与WCF无关。类包代码中存在问题,没有抛出任何错误。抱歉&感谢daniell89,Shuto Mbofana,