2013-05-21 55 views
0

我有一個ASP.Net網站,從WCF託管站點(IIS)獲取所有業務邏輯。有一段時間,它看起來像後端WCF凍結,並使網絡前端停止響應。我必須回收這兩個應用程序池才能使其再次運行。WCF停止響應interbitently

  • 最近發生的情況更多,可能是因爲我們有更多&使用該網站的客戶。之前,它每月發生一次,現在每週發生一次。也許更多。
  • 我們在每次SVC呼叫後關閉連接。在事件日誌接收
  • 錯誤消息後我回收池

消息:System.ServiceModel.CommunicationException:在接收到HTTP響應時發生錯誤........... /.....BusinessServices.svc。這可能是由於服務端點綁定不使用HTTP協議。這也可能是由於HTTP請求上下文被服務器中止(可能是由於服務關閉)。查看服務器日誌獲取更多詳細信---> System.Net.WebException:底層連接已關閉:接收時發生意外錯誤。 ---> System.IO.IOException:無法從傳輸連接讀取數據:現有連接被遠程主機強制關閉。 ---> System.Net.Sockets.SocketException:

<bindings> 
<wsHttpBinding> 
<binding name="WSHttpBinding_IBusinessServices" closeTimeout="00:31:00" openTimeout="00:31:00" 
receiveTimeout="00:10:00" sendTimeout="00:31:00" 
bypassProxyOnLocal="false" transactionFlow="false" 
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
maxReceivedMessageSize="2147483647" messageEncoding="Text" 
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
    <readerQuotas maxDepth="999" maxStringContentLength="2147483647" maxArrayLength="1638400" 
    maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
    <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 
     <security mode="Message"> 
      <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> 
      </security> 
    </binding> 
     </wsHttpBinding> 
     </bindings> 
    <client> 
    <endpoint address="http://localhost:8890/MyBusinessServices.svc" binding="wsHttpBinding" 
bindingConfiguration="WSHttpBinding_IBusinessServices" 
contract="MyBusinessServices.IBusinessServices" 
name="WSHttpBinding_IBusinessServices" /> 
</client> 
:一個現有的連接被強制由遠程主機的web應用程序的

  • Web.config中關閉
    • WCF服務的Web.config,將節流設置爲1500

      .....

      <behavior name="AppServiceBehaviors"> 
           <serviceMetadata httpGetEnabled="true" /> 
           <serviceDebug includeExceptionDetailInFaults="true" /> 
           <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
           <serviceTimeouts transactionTimeout="00:15:00" /> 
           <serviceThrottling maxConcurrentCalls="1500" maxConcurrentSessions="1500" 
           maxConcurrentInstances="2147483647" /> 
          </behavior> 
      
          <behavior name=""> 
           <serviceMetadata httpGetEnabled="true" /> 
           <serviceDebug includeExceptionDetailInFaults="true" /> 
           <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
          </behavior> 
          </serviceBehaviors> 
      </behaviors> 
      

    這個問題是間歇性的,但它讓我發瘋。任何想法/建議表示讚賞。

    埃裏克

回答

0

你面對現在可以投出的問題,由於需要更大量的描述比我們目前有很多其他因素。

拋出的異常是一種可能指向許多場景的一般異常。例如,如果您的服務服務器前有一個負載平衡器,並且其中一個負載平衡器在運行時出現錯誤,但另一個則不是。另一個例子是sql server在服務器端創建一個異常,但是你的包裝異常可能不會把相關信息發送給你的客戶端。所以你不知道到底發生了什麼。

我有幾個建議您檢查:

我可以看到你表示,你是關閉每次通話後連接。但是您需要確保接收到異常的調用也被關閉。所以你的svc電話應該看起來像這樣:

try 
    { 
    if (this.client != null) 
    { 
     IClientChannel channel = this.client as IClientChannel; 
     if (channel.State == CommunicationState.Faulted) 
     { 
      channel.Abort(); 
     } 
     else 
     { 
      channel.Close(); 
     } 
    } 
    } 
    finally 
    { 
    this.client = null; 
    } 

除此之外,你可能還想檢查你的IIS上的應用程序池設置。您可以從事件日誌中確認,您不必強制以「最大失敗次數」設置進行回收/關閉。 (在高級應用程序池設置 - rapidFailProtectionMaxCrashes)

0

我的2分錢給你,

服務中斷 - 錯誤由於致命錯誤發生裏面,

確認,而在VS IDE的開發調試WCF,保持例外(Ctrl D,E),檢查所有「未處理的異常」列。這使IDE可以精確地分割應用程序代碼行,儘管CATCHes..This將發現任何錯誤。

請不要讓我們知道,如果在這裏任何結果......

好運, HydTechie