2011-07-29 31 views
2

我收到了許多異常(〜100每小時?),導致跟蹤文件隨着時間的推移變得臃腫。沒有任何關於系統變得不穩定的報告,所以它不會顯着影響服務的性能。跟蹤始終是相同的:WCF套接字連接中止填滿跟蹤文件

Information - Aborted 'System.ServiceModel.Channels.ServiceChannel/32909893' 

Information - Aborted 'System.ServiceModel.Channels.ServerSessionPreambleConnectionReader+ServerFramingDuplexSessionChannel/12895634' 

Warning - SocketConnection aborted 

Error - Throwing an exception 
Message: 
A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data. 
Stack Trace: 
System.ServiceModel.Channels.SocketConnection.EndRead() 
System.ServiceModel.Channels.DelegatingConnection.EndRead() 
System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
System.ServiceModel.Channels.SocketConnection.FinishRead() 
System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) 
System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped) 
System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) 
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 

Error - Throwing an exception 
Message: 
A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data. 
Stack Trace: 
System.ServiceModel.Channels.SocketConnection.EndRead() 
System.ServiceModel.Channels.DelegatingConnection.EndRead() 
System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
Error - Throwing an exception 
Message: 
A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data. 
Stack Trace: 
System.ServiceModel.Channels.SessionConnectionReader.GetPendingMessage() 
System.ServiceModel.Channels.SessionConnectionReader.EndReceive() 
System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state) 

Error - Throwing an exception 
Message: 
A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data. 
Stack Trace: 
System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) 
System.ServiceModel.Channels.FramingDuplexSessionChannel.EndReceive(IAsyncResult result) 
System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.CompleteReceive(IAsyncResult result) 
System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result) 

在我的研究,我發現這是一個相當普遍的問題,它似乎和答案通常是爲了增加超時/ maxRecievedMessageSize在服務端和客戶端的配置文件。

的配置文件如下

WCF服務的配置:

<system.serviceModel> 
<bindings> 
    <netTcpBinding> 
    <binding name="customNetTcpBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="10485760" maxBufferSize="10485760"> 
     <security mode="None" /> 
    <readerQuotas maxStringContentLength="10485760"/> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<diagnostics> 
    <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" /> 
</diagnostics> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
<services> 
    <service behaviorConfiguration="WcfServiceLibrary.ServiceBehavior" 
    name="xxx.xxx.xxx"> 
    <endpoint address="Endpoint" binding="netTcpBinding" bindingConfiguration="customNetTcpBinding" 
     name="netTcpBinding" contract="xxx.xxx.xxx"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
     name="mexTcpBinding" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="xxx.xxx.xxx" /> 
     </baseAddresses> 
    </host> 
    </service> 
    <service behaviorConfiguration="WcfServiceLibrary.ServiceBehavior" 
     name="xxx.xxx.xxx"> 
     <endpoint address="EndPoint" binding="netTcpBinding" bindingConfiguration="customNetTcpBinding" 
      name="netTcpBinding" contract="xxx.xxx.xxx" listenUriMode="Explicit"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
      name="mexTcpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
       <add baseAddress="xxx.xxx.xxx" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="WcfServiceLibrary.ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" /> 
     <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" /> 
     <serviceThrottling maxConcurrentCalls="16" 
         maxConcurrentInstances="2147483647" 
         maxConcurrentSessions="64"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

客戶端配置

<system.serviceModel> 
<bindings> 
    <netTcpBinding> 
    <binding name="xxxx" closeTimeout="00:05:00" openTimeout="00:05:00" 
     receiveTimeout="00:10:00" sendTimeout="00:05:00" transactionFlow="false" 
     transferMode="Buffered" transactionProtocol="OleTransactions" 
     hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" 
     maxBufferSize="10485760" maxConnections="10" maxReceivedMessageSize="10485760"> 
     <readerQuotas maxDepth="32" maxStringContentLength="10485760" 
     maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
     enabled="false" /> 
     <security mode="None"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     <message clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    <binding name="xxxx" closeTimeout="00:05:00" openTimeout="00:01:00" 
     receiveTimeout="00:10:00" sendTimeout="00:05:00" transactionFlow="false" 
     transferMode="Buffered" transactionProtocol="OleTransactions" 
     hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" 
     maxBufferSize="10485760" maxConnections="10" maxReceivedMessageSize="10485760"> 
     <readerQuotas maxDepth="32" maxStringContentLength="10485760" 
     maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
     enabled="false" /> 
     <security mode="None"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     <message clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<client> 
    <endpoint address="xxx.xxx.xxx" binding="netTcpBinding" 
    bindingConfiguration="xxxx" contract="xxx.xxx.xxx" 
    name="xxxx"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
    <endpoint address="xxx.xxx.xxx" binding="netTcpBinding" 
    bindingConfiguration="xxxx" contract="xxx.xxx.xxx" 
    name="xxxx"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
</client> 

這似乎fairl y慷慨嗎?還是這樣,我只需要增加數字或者是其他的東西?

+0

找到解決方案?請告訴我們 – user758977

回答

1

這些錯誤可能是由網絡丟包引起的嗎?

我從配置文件中看到您正在使用啓用了可靠會話的綁定。這意味着,如果服務器未收到客戶端收到消息的確認,則網絡丟失的任何消息都將自動重新發送。這可以解釋爲什麼你沒有看到你的服務中斷;記錄失敗,然後服務器重新發送成功。

如果您想測試這是否確實是問題,請嘗試關閉配置文件中的可靠會話。您將需要在客戶端和服務器配置文件(作爲綁定定義的一部分)中明確指定此明確,因爲我認爲netTCP綁定在默認情況下會執行此操作。

<reliableSession enabled="false" /> 

如果上面是不是一種選擇,你可以嘗試,那麼你可以問你的網絡管理員做跟蹤,並查看是否有丟包。

我希望這有助於:)