我有一个.NET Remoting服务,大部分时间工作正常.如果发生异常或错误,它会将错误记录到文件中,但仍会继续运行.
但是,大约每两周一次,服务将停止响应客户端,这会导致客户端应用程序与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
没有例外或堆栈跟踪写入我们的日志文件,所以我无法确定服务崩溃的位置,这导致我相信它是在我的代码之外的地方失败.我可以采取什么额外的步骤来弄清这个崩溃的根本原因?我会想像它在某个地方写入一个EventLog,但是我并不是非常熟悉Windows的事件记录系统,所以我不太清楚在哪里看.
提前感谢任何协助.
编辑:忘记提及,停止或重新启动服务什么也不做,服务永远不会响应.我需要手动杀死该进程,然后再重新启动该服务.
编辑2:
public class ClientInfoServerSinkProvider : IServerChannelSinkProvider { private IServerChannelSinkProvider _nextProvider = null; public ClientInfoServerSinkProvider() { } public ClientInfoServerSinkProvider( IDictionary properties,ICollection providerData) { } public IServerChannelSinkProvider Next { get { return _nextProvider; } set { _nextProvider = value; } } public IServerChannelSink CreateSink(IChannelReceiver channel) { IServerChannelSink nextSink = null; if (_nextProvider != null) { nextSink = _nextProvider.CreateSink(channel); } return new ClientIPServerSink(nextSink); } public void GetChannelData(IChannelDataStore channelData) { } } public class ClientIPServerSink : BaseChannelObjectWithProperties,IServerChannelSink,IChannelSinkBase { private IServerChannelSink _nextSink; public ClientIPServerSink(IServerChannelSink next) { _nextSink = next; } public IServerChannelSink NextChannelSink { get { return _nextSink; } set { _nextSink = value; } } public void AsyncProcessResponse( IServerResponseChannelSinkStack sinkStack,Object state,IMessage message,ITransportHeaders headers,Stream stream) { IPAddress ip = headers[CommonTransportKeys.IPAddress] as IPAddress; CallContext.SetData("ClientIPAddress",ip); sinkStack.AsyncProcessResponse(message,headers,stream); } public Stream GetResponseStream( IServerResponseChannelSinkStack sinkStack,ITransportHeaders headers) { return null; } public ServerProcessing ProcessMessage( IServerChannelSinkStack sinkStack,IMessage requestMsg,ITransportHeaders requestHeaders,Stream requestStream,out IMessage responseMsg,out ITransportHeaders responseHeaders,out Stream responseStream) { if (_nextSink != null) { IPAddress ip = requestHeaders[CommonTransportKeys.IPAddress] as IPAddress; CallContext.SetData("ClientIPAddress",ip); ServerProcessing spres = _nextSink.ProcessMessage( sinkStack,requestMsg,requestHeaders,requestStream,out responseMsg,out responseHeaders,out responseStream); return spres; } else { responseMsg = null; responseHeaders = null; responseStream = null; return new ServerProcessing(); } }
解决方法
这就是试图找出当你打电话给朋友时为什么没有人拿起电话.问题是他的房子烧毁了地面.一个不完美的观点是发生了什么是核心问题,特别是服务质量差,因为没有什么可观的.
直到您使用该电话与服务程序员交谈并让他参与到这个问题之前,这才能变得更好.有人会调试这个.是的,这将是困难的,每两周失败一次可能不被认为是至关重要的.还是太久了,等待着发生.只有实际的事情,你可以做的帮助是创建一个minidump的过程,并将其传递给服务程序员,所以他有一些东西要戳.如果服务在另一台机器上运行,那么也需要涉及LAN管理员.