WCF socket connection aborted filling up trace file
I am getting many exceptions (~100 per hour?) which is causing the trace file to become bloated over time. Have not had any reports of the system becoming unstable, so it's not overtly affecting the performance of the service. The trace is always the same:
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)
In my research i have found this to be a fairly common question and it seems and the answer is usually to increase the timeout/maxRecievedMessageSize in the config file of the service and client.
The config files are as follows
WCF service config:
<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="WcfS开发者_如何学GoerviceLibrary.ServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="16"
maxConcurrentInstances="2147483647"
maxConcurrentSessions="64"/>
</behavior>
</serviceBehaviors>
</behaviors>
Client config
<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>
This seems fairly generous? Is it still the case that i just need to increase the numbers or is it something else?
Could these errors be caused by packet loss on your network?
I see from your config file that you are using a binding that has reliable sessions enabled. This means that any messages that get lost by the network will be automatically resent if the server does not receive acknowledgement that the client received the message. This could explain why you are not seeing any disruption in your service; the failure is logged and then the server resends successfully.
If you want to test if this is indeed the issue, try switching off reliable sessions in the config file. You will need to specify this explicitly in both the client and the server config files (as part of the binding definition), as I think the netTCP binding does this by default.
<reliableSession enabled="false" />
If the above isn't an option that you can try, then you could ask your network admin to do a trace and see if there is packet loss.
I hope this helps :)
精彩评论