当服务器上抛出远程处理异常时,出现套接字关闭错误

发布于 2024-07-06 10:19:49 字数 1257 浏览 6 评论 0原文

我有一个使用 .Net 远程处理构建的应用程序。 身份验证时,如果出现错误,我会在服务器上抛出异常。 该异常是可序列化的。 但是,当服务器上引发异常时,有时我会在客户端看到错误,提示“已建立的连接被主机中的软件中止”。

这是我在尝试调试服务器时从 Windbg 获得的堆栈跟踪。 看起来远程处理框架正在这样做。 关于为什么套接字被关闭以及如何处理这个问题有什么想法吗?

System.Net.Sockets.Socket.Close()
System.Runtime.Remoting.Channels.SocketHandler.Close()
System.Runtime.Remoting.Channels.SocketHandler.CloseOnFatalError(System.Exception)
System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
System.Runtime.Remoting.Channels.RequestQueue.ProcessNextRequest(System.Runtime.Remoting.Channels.SocketHandler)
System.Runtime.Remoting.Channels.SocketHandler.BeginReadMessageCallback(System.IAsyncResult)
System.Net.LazyAsyncResult.Complete(IntPtr)
System.Net.ContextAwareResult.CompleteCallback(System.Object)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
System.Net.ContextAwareResult.Complete(IntPtr)
System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

I have an app that is built using .Net remoting. When authenticating, If there is an error, I threw an exception on the server. The exception is serializable. But when the exception is thrown on the server, Sometimes I see an error on the client side that says "An established connection was aborted by the software in your host machine".

This is the stack trace I have from windbg when try to debug the server. Looks like the remoting framework is doing that. Any ideas as to why the socket is being closed and how to handle this?

System.Net.Sockets.Socket.Close()
System.Runtime.Remoting.Channels.SocketHandler.Close()
System.Runtime.Remoting.Channels.SocketHandler.CloseOnFatalError(System.Exception)
System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
System.Runtime.Remoting.Channels.RequestQueue.ProcessNextRequest(System.Runtime.Remoting.Channels.SocketHandler)
System.Runtime.Remoting.Channels.SocketHandler.BeginReadMessageCallback(System.IAsyncResult)
System.Net.LazyAsyncResult.Complete(IntPtr)
System.Net.ContextAwareResult.CompleteCallback(System.Object)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
System.Net.ContextAwareResult.Complete(IntPtr)
System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2024-07-13 10:19:49

每次抛出远程异常时,.Net 远程处理框架都会关闭套接字吗? 从使用WinDbg调试来看,情况就是如此。 有人可以证实这一点吗? 另外,是否有时在发送响应后关闭套接字,有时在发送响应之前关闭套接字,具体取决于特定情况?

这是当我没有得到“已建立的连接被主机中的软件中止”时来自客户端的 Windbg 的跟踪。 在这种情况下,我收到远程处理异常

06d2f45c 7c812aeb [HelperMethodFrame: 06d2f45c] 
06d2f500 7a5ff43e System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
06d2f51c 67777fb0 System.Runtime.Remoting.Channels.SocketStream.Read(Byte[], Int32, Int32)
06d2f530 67777b12 System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[], Int32, Int32)
06d2f540 67777aea System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
06d2f548 67777a7c System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[], Int32, Int32)
06d2f56c 67777998 System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[])
06d2f578 67783199 System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16 ByRef)
06d2f598 67783ece System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
06d2f5b4 67782456 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5d0 06e61bdf com.imageright.security.remoting.IdentityClientSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5f0 6778ae69 System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
06d2f62c 793c319f System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Contexts.ArrayWithSize, System.Threading.Thread, System.Runtime.Remoting.Contexts.Context, Boolean)
06d2f650 793c2f82 System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage, Boolean, Int32)
06d2f6b4 793c2db9 System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage)
06d2f6c4 79374dc3 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
06d2f960 79f98b43 [TPMethodFrame: 06d2f960] com.imageright.server.IInstrumentation.GetEnterpriseID()
06d2f970 06e618ee imageright.proxies_com.imageright.server.IInstrumentationProxy.GetEnterpriseID()
06d2f9c4 069fddae ImageRight.EMC.EnterpriseNode.EstablishConnection()
06d2fa00 069fdce7 ImageRight.EMC.RootNode.TryOpenConnections(System.Object)
06d2fa38 79407caa System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Object)
06d2fa3c 79373ecd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
06d2fa54 79407e18 System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
06d2fa68 79407d90 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
06d2fbf8 79e7c74b [GCFrame: 06d2fbf8] 

这是当我收到错误“已建立的连接被主机中的软件中止”时的跟踪。 在这种情况下,我收到套接字错误。

06d2f45c 7c812aeb [HelperMethodFrame: 06d2f45c] 
06d2f500 7a5ff43e System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
06d2f51c 67777fb0 System.Runtime.Remoting.Channels.SocketStream.Read(Byte[], Int32, Int32)
06d2f530 67777b12 System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[], Int32, Int32)
06d2f540 67777aea System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
06d2f548 67777a7c System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[], Int32, Int32)
06d2f56c 67777998 System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[])
06d2f578 67783199 System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16 ByRef)
06d2f598 67783ece System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
06d2f5b4 67782456 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5d0 06e61bdf com.imageright.security.remoting.IdentityClientSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5f0 6778ae69 System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
06d2f62c 793c319f System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Contexts.ArrayWithSize, System.Threading.Thread, System.Runtime.Remoting.Contexts.Context, Boolean)
06d2f650 793c2f82 System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage, Boolean, Int32)
06d2f6b4 793c2db9 System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage)
06d2f6c4 79374dc3 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
06d2f960 79f98b43 [TPMethodFrame: 06d2f960] com.imageright.server.IInstrumentation.GetEnterpriseID()
06d2f970 06e618ee imageright.proxies_com.imageright.server.IInstrumentationProxy.GetEnterpriseID()
06d2f9c4 069fddae ImageRight.EMC.EnterpriseNode.EstablishConnection()
06d2fa00 069fdce7 ImageRight.EMC.RootNode.TryOpenConnections(System.Object)
06d2fa38 79407caa System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Object)
06d2fa3c 79373ecd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
06d2fa54 79407e18 System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
06d2fa68 79407d90 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
06d2fbf8 79e7c74b [GCFrame: 06d2fbf8].

在服务器上抛出异常的是我们负责安全的自定义接收器。 我可以直接将代码发布在一个地方。

Is it the case that the .Net remoting framework closes the socket everytime a remoting exception is thrown? from debugging using WinDbg, that looks to the case. Could some one confirm this? Also, Is it the case some times the socket is closed after the reponse is sent and sometimes the socket is closed before the response is sent depending on an particular scenario?

This is trace from windbg on the client side when I don't get that "An established connection was aborted by the software in your host machine". In this case, I get a remoting exception

06d2f45c 7c812aeb [HelperMethodFrame: 06d2f45c] 
06d2f500 7a5ff43e System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
06d2f51c 67777fb0 System.Runtime.Remoting.Channels.SocketStream.Read(Byte[], Int32, Int32)
06d2f530 67777b12 System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[], Int32, Int32)
06d2f540 67777aea System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
06d2f548 67777a7c System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[], Int32, Int32)
06d2f56c 67777998 System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[])
06d2f578 67783199 System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16 ByRef)
06d2f598 67783ece System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
06d2f5b4 67782456 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5d0 06e61bdf com.imageright.security.remoting.IdentityClientSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5f0 6778ae69 System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
06d2f62c 793c319f System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Contexts.ArrayWithSize, System.Threading.Thread, System.Runtime.Remoting.Contexts.Context, Boolean)
06d2f650 793c2f82 System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage, Boolean, Int32)
06d2f6b4 793c2db9 System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage)
06d2f6c4 79374dc3 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
06d2f960 79f98b43 [TPMethodFrame: 06d2f960] com.imageright.server.IInstrumentation.GetEnterpriseID()
06d2f970 06e618ee imageright.proxies_com.imageright.server.IInstrumentationProxy.GetEnterpriseID()
06d2f9c4 069fddae ImageRight.EMC.EnterpriseNode.EstablishConnection()
06d2fa00 069fdce7 ImageRight.EMC.RootNode.TryOpenConnections(System.Object)
06d2fa38 79407caa System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Object)
06d2fa3c 79373ecd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
06d2fa54 79407e18 System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
06d2fa68 79407d90 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
06d2fbf8 79e7c74b [GCFrame: 06d2fbf8] 

This is the trace when I get that error "An established connection was aborted by the software in your host machine". In this case I get a socket error.

06d2f45c 7c812aeb [HelperMethodFrame: 06d2f45c] 
06d2f500 7a5ff43e System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
06d2f51c 67777fb0 System.Runtime.Remoting.Channels.SocketStream.Read(Byte[], Int32, Int32)
06d2f530 67777b12 System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[], Int32, Int32)
06d2f540 67777aea System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
06d2f548 67777a7c System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[], Int32, Int32)
06d2f56c 67777998 System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[])
06d2f578 67783199 System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16 ByRef)
06d2f598 67783ece System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
06d2f5b4 67782456 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5d0 06e61bdf com.imageright.security.remoting.IdentityClientSink.ProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Channels.ITransportHeaders, System.IO.Stream, System.Runtime.Remoting.Channels.ITransportHeaders ByRef, System.IO.Stream ByRef)
06d2f5f0 6778ae69 System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
06d2f62c 793c319f System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink, System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Contexts.ArrayWithSize, System.Threading.Thread, System.Runtime.Remoting.Contexts.Context, Boolean)
06d2f650 793c2f82 System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage, Boolean, Int32)
06d2f6b4 793c2db9 System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage)
06d2f6c4 79374dc3 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData ByRef, Int32)
06d2f960 79f98b43 [TPMethodFrame: 06d2f960] com.imageright.server.IInstrumentation.GetEnterpriseID()
06d2f970 06e618ee imageright.proxies_com.imageright.server.IInstrumentationProxy.GetEnterpriseID()
06d2f9c4 069fddae ImageRight.EMC.EnterpriseNode.EstablishConnection()
06d2fa00 069fdce7 ImageRight.EMC.RootNode.TryOpenConnections(System.Object)
06d2fa38 79407caa System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(System.Object)
06d2fa3c 79373ecd System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
06d2fa54 79407e18 System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback)
06d2fa68 79407d90 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(System.Object)
06d2fbf8 79e7c74b [GCFrame: 06d2fbf8].

And the one that is throwing the exception on the server is our custom sink that takes care of security. I could have posted the code If it as in one place and straight forward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文