服务器调用期间的WCF通信异常

时间:2013-06-11 21:38:20

标签: c# wcf asp.net-mvc-4 communicationexception

我正在黑暗中拍摄这个但是我遇到了一个问题,我希望有人可能会遇到过......我的客户端发出了一个服务器调用,它几乎只是从一个Sql server DB并将其返回给我的客户端,但有时客户端永远不会收到来自Server的响应。我放了一堆登录,最后一行服务器端代码被执行但是,客户端永远不会收到响应,因此卡住“PROCESSING”...我添加了一个WCF跟踪并使用服务对其进行监控跟踪查看器。

WCF Activity Trace

我在活动日志中看到包含以下文本的例外:

    <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>

我认为之前没有人见过这样的东西,可以给我一些关于如何修复它的建议吗?任何信息都将不胜感激。

谢谢!

1 个答案:

答案 0 :(得分:3)

一个CommunicationException,错误消息如“套接字连接已中止。这可能......”只是一般故障情况,是实际错误的副作用。

要了解实际错误是什么,请使用您的WCF跟踪输出。选择标记为Exceptions的项目,然后查看详细信息窗格。其中一个很可能会为您提供更明确的错误信息 - 这可能与您迄今提供的内容有关。

在客户端和服务器上建立跟踪,当您在跟踪窗口中看到异常时,突出显示它以在右侧窗格中显示更多详细信息。