我们有一个WCF服务,它在启动时通过Net.Pipes协议调用其他几个服务。调用返回一个字符串列表,no Enum或复杂对象。
有时,我们会收到以下异常。
System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d).
at System.ServiceModel.Channels.PipeConnection.FinishSyncRead(Boolean traceExceptionsAsErrors)
at System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
--- End of inner exception stack trace ---
这并不是每次都会发生。我几乎找不到任何关于这个错误的参考资料。
我想知道,为什么会发生这种情况,以及如何预防。
发布于 2015-02-10 11:09:58
一个可能的原因是,当web服务试图执行其工作时,您的应用程序池正在回收。
将其配置为在特定时间运行:
打开IIS管理器。 在“连接”窗格中,展开服务器节点并单击“应用程序池”。 在“应用程序池”页上,选择一个应用程序池,然后在“操作”窗格中单击“回收”。 选择特定时间,并在相应的框中键入希望应用程序池每天循环的时间。例如,类型为上午11:30或晚上11:30
另一个原因可能是您的邮件负载太大。增加服务器端和客户端的连接关闭时间。顺便说一下,超时可能不仅是因为消息大小,而且也是因为系统太忙(CPU处于100%状态,持续一段时间),或者因为启动服务需要花费太多的时间(在这种情况下,预编译可能会有所帮助)。
为应用程序配置跟踪可能有助于诊断问题:https://msdn.microsoft.com/en-us/library/ms733025.aspx
发布于 2015-01-20 11:38:33
为什么会发生这种事?
正如错误已经指出的:在读操作之前管道是关闭的,有机会运行。
如何预防?
别把手柄关上。手柄可以通过以下几种方式关闭:
Abort()
函数。Close()
函数。DuplicateAndClose()
函数。https://stackoverflow.com/questions/28044133
复制相似问题