Franco Trombetta
Franco Trombetta

Reputation: 207

WCF Communication Exception During Server Call

I'm taking a shot in the dark with this one but I've been experiencing an issue that I'm hoping someone might have come across before...My client makes a server call which pretty much just grabs data from a Sql server DB and returns it to my client however sometimes the client never receives a response from the Server. I put a bunch of logging in and the very last line of server side code is executed but still, the client never receives the response and as a result gets stuck "PROCESSING"... I added a WCF trace and monitored it using the Service Trace Viewer.

WCF Activity Trace

And I'm seeing exceptions in the Activity logs that contain the following text:

    <E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
    <EventID>131075</EventID>
    <Type>3</Type>
    <SubType Name="Error">0</SubType>
    <Level>2</Level>
    <TimeCreated SystemTime="2013-06-11T19:38:52.8094768Z" />
    <Source Name="System.ServiceModel" />
    <Correlation ActivityID="{a3b3598e-8ce1-4afc-8cf2-89c6fa505061}" />
    <Execution ProcessName="TwoFour.WCF.App" ProcessID="5056" ThreadID="111" />
    <Channel />
    <Computer>VA3WEB-REMEDY01</Computer>
    </System>
    <ApplicationData>
    <TraceData>
    <DataItem>
    <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
    <TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
    <Description>Throwing an exception.</Description>
    <AppDomain>TwoFour.WCF.App.exe</AppDomain>
    <Exception>
    <ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
    <Message>The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '10675199.02:48:05.4775807'.</Message>
    <StackTrace>
    at System.ServiceModel.Channels.SocketConnection.EndRead()
    at System.ServiceModel.Channels.TracingConnection.EndRead()
    at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
    at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
    at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
    at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
    </StackTrace>
    <ExceptionString>System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '10675199.02:48:05.4775807'. ---&gt; System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
       --- End of inner exception stack trace ---</ExceptionString>
    <InnerException>
    <ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
    <Message>An existing connection was forcibly closed by the remote host</Message>
    <StackTrace>
    at System.ServiceModel.Channels.SocketConnection.EndRead()
    at System.ServiceModel.Channels.TracingConnection.EndRead()
    at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
    at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
    at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
    at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
    </StackTrace>
    <ExceptionString>System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host</ExceptionString>
    <NativeErrorCode>2746</NativeErrorCode>
    </InnerException>
    </Exception>
    </TraceRecord>
    </DataItem>
    </TraceData>    
</ApplicationData>

I don't suppose anyone has seen something like this before and can give me some recommendations as to how I can go about fixing it? Any information would be greatly appreciated.

Thanks!

Upvotes: 0

Views: 4394

Answers (1)

RJ Lohan
RJ Lohan

Reputation: 6527

A CommunicationException with an error message like "The socket connection was aborted. This could be..." is just a general failure condition and is the side-effect of the actual error.

To find out what the actual error is, use your WCF trace output. Select the items marked as Exceptions and look at the details pane for those. One of them will most likely give you more explicit information as to the error - which really could be anything from what you've provided so far.

Establish tracing on both the client and server, and when you see an exception in the trace window, highlight it to show more details in the right-hand-side panes.

Upvotes: 3

Related Questions