2 つのサーバー間でオブジェクトを送信するために .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)
数時間後、「メモリ不足の例外」が原因でアプリケーションがクラッシュし、ダンプ ファイルから、送信しようとしたすべてのオブジェクトがまだリモート オブジェクトの 1 つによって参照されているため、GC によって収集されていないことがわかります。メモリリークを回避するために EndInvoke で例外を処理する正しい方法は何ですか?
この問題は、クライアント側の変更によって発生または修正される可能性があることを理解していますが、サーバーの堅牢性を確保するためにサーバー側でどのような変更を行うことができるかを理解することが重要です。