WCF Named Pipe IO Exception - The pipe has been ended. (109, 0x6d)

巧了我就是萌 提交于 2020-01-17 07:08:05

问题


We have a WCF service which calls several other services through Net.Pipes protocol on start up. The call return a list of string, no Enum or complex objects.

Sometimes, we receive the following exception.

    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 ---

It does not occur every time. I could not find almost any references to this error.

I would like to know, why does it happens and how to prevent it.


回答1:


A possible reason is that your Application Pool is recycling when the web service is trying to perform its work.

Configure it to run at specific time:

Open IIS Manager.

In the Connections pane, expand the server node and click Application Pools.

On the Application Pools page, select an application pool, and then click Recycling in the Actions pane.

Select Specific time(s), and in the corresponding box type a time at which you want the application pool to recycle daily. For example, type 11:30 AM or 11:30 PM.

Another reason could be that your message payload is too big. Increase connection close timings both on server and client side. BTW the timeout may occur not only because of message size, but also because the system was too busy (CPU at 100% for some time) or because it takes too much time for the service to startup (precompilation may help in this case).

Configuring tracing for your application may help to diagnose the problem: https://msdn.microsoft.com/en-us/library/ms733025.aspx




回答2:


Why does it happen?

As the error already says: the pipe is closed before read operation has chance to run.

How to prevent it?

Don't close the Handle. Handle can be closed in few ways:

  • If the Abort() function is called.
  • If the Close() function is called.
  • If the DuplicateAndClose() function is called.


来源:https://stackoverflow.com/questions/28044133/wcf-named-pipe-io-exception-the-pipe-has-been-ended-109-0x6d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!