1

我正在使用 .Net Remoting 在两台服务器之间发送对象。在我使用 EndInvoke 的这种情况下,对象由“Begin Invoke”机制发送,但在 End Invoke 期间始终抛出以下异常:

System.Net.WebExceptionSystem.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond …
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.AsyncHttpClientRequestState.ProcessGetRequestStreamCompletion(IAsyncResult iar)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Core.Common.CLSAPI.EventArrivedHandler.EndInvoke(IAsyncResult result)

几个小时后,我的应用程序由于“内存不足异常”而崩溃,并且从转储文件中我可以看到,我尝试发送的所有对象仍被其中一个远程对象引用,因此 GC 仍未收集。在 EndInvoke 中处理异常以避免内存泄漏的正确方法是什么?

我知道这个问题可能是由客户端的一些更改引起/修复的,但是对我来说了解我可以在服务器端进行哪些更改以确保我的服务器的稳健性很重要。

4

0 回答 0