2017-03-16 85 views
0

我在使用我的WCF服務時遇到問題。我在控制檯應用程序中使用了我的WCF服務,它可以正常工作,直到100個請求(在一個循環中)。但它在100次請求後停止工作。我已經在我的配置中使用了WCF服務在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> 
+0

真的很傻什麼錯誤,你讓當您啓用FaultExceptions? –

+0

嗨種兔, 作爲事實上,我沒有得到任何異常或者 我是新來的WCF,可能是我做錯了什麼: 公開名單 GetDestinationHotelId(字符串DestinationAirport) { 嘗試 { 包objPkg =新包(); 回報objPkg.GetDestinationHotelId(DestinationAirport);} catch(Exception fe) { throw new FaultException(fe.Message); } //返回null; } 以上是我的服務合同方法。 – kulesshhh

+0

以下是我的客戶端應用程序代碼使用它: int x = 0; while(true) { x ++;使用(AirGainUtilities.Service.UtilitiesClient UC = new AirGainUtilities.Service.UtilitiesClient()) 列表 lstHotels = UC.GetDestinationHotelId(「SJD」);如果(lstHotels.Count <= 0) { x ++; } } } – kulesshhh

回答

0

顯然,問題是在包裝類的GetDestinationHotelId方法的開放數據庫連接。 DB連接由於例外而未關閉,並且在打開100個連接後MAX CONNECTION POOL LIMIT已達到。

在我結束:-(