2017-06-16 41 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中的連接字符串不正確,導致數據庫連接旋轉,直到數據庫連接超時。數據庫連接超時設置爲高於服務/客戶端的超時,因此客戶端在發生數據庫超時之前會超時。由於不需要爲我們記錄失敗的日誌記錄,因此數據庫連接超時將靜默地發生。

修復連接字符串使服務迅速響應。

這個故事的寓意:仔細檢查您的功能 - 即使他們看起來似乎很簡單,他們可能引擎蓋:)