none
Error reading from the pipe

    Question

  • Hi. I'm trying to pass message that's about 60MB from one wcf service to another via net.pipe and i'm constantly getting an exception Error Reading From the pipe. Anyone knows the solution?

    What is message size limit for net.pipe binding?

     

    There was an error reading from the pipe: Unrecognized error 109 (0x6d). ---> System.IO.PipeException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). 
        at System.ServiceModel.Channels.PipeConnection.StartSyncRead(Byte[] buffer, Int32 offset, Int32 size, Object& holder) 
       at System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout) 
       --- End of inner exception stack trace --- 

    Server stack trace:  
        at System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout) 
       at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout) 
       at System.ServiceModel.Channels.SessionConnectionReader.Receive(TimeSpan timeout) 
      at System.ServiceModel.Channels.SynchronizedMessageSource.Receive(TimeSpan timeout) 
      at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnClose(TimeSpan timeout) 
      at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 
        at System.ServiceModel.Channels.ServiceChannel.OnClose(TimeSpan timeout) 
        at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 
       at System.ServiceModel.Channels.CommunicationObject.Close() 
       at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose() 
     
    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 System.IDisposable.Dispose() 
       at Microsoft.ServiceModel.Samples.SoapRouter.SendMessage(Message message) 
       at Pexim.Ibank.BankAdapterRouter.ServiceImplementation.SoapRouter.GetAccountChangesDelta(Message message)
    System.IO.PipeException: There was an error reading from the pipe: Unrecognized error 109 (0x6d). 
       at System.ServiceModel.Channels.PipeConnection.StartSyncRead(Byte[] buffer, Int32 offset, Int32 size, Object& holder) 
      at System.ServiceModel.Channels.PipeConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)

    Tuesday, August 14, 2007 4:09 PM

Answers

  • Generelly the pipe error indicate some kind of communication  issue.  I would suggest you to try with smaller message size and let me know if it works. Also try enabling the diagonistic tracing for the scenario. The tracing will provide better insight into what could be wrong here. for details refer http://msdn2.microsoft.com/en-us/library/ms733025.aspx.

    Also verify the application/System eventlog entries for any suspicious entry.

     

    -Jandeep

    Thursday, August 23, 2007 9:15 PM

All replies

  • There can be several causes for this, the message size being just one.

    Can you share your endpoint config? Did you already try to increase the quotas?

    Tuesday, August 14, 2007 5:40 PM
  • Is this exception thrown on the client or the service side?

    Wednesday, August 15, 2007 12:23 AM
  • Well i don't use standard wcf endpoint configuration, rather i do it from the code:

    Part of code that describe binding:

    public class RouterBinding : Binding, IBindingRuntimePreferences

    {

    MessageEncoding messageEncoding;

    RouterTransport transport;

    HttpTransportBindingElement httpTransport;

    TcpTransportBindingElement tcpTransport;

    NamedPipeTransportBindingElement namedPipeTransport;

    TextMessageEncodingBindingElement textEncoding;

    MtomMessageEncodingBindingElement mtomEncoding;

    BinaryMessageEncodingBindingElement binaryEncoding;

    public RouterBinding()

    : base()

    {

    Initialize();

    }

    public RouterBinding(string configurationName)

    : this()

    {

    ApplyConfiguration(configurationName);

    }

    public RouterBinding(RouterTransport transport)

    : this()

    {

    this.Transport = transport;

    if (transport == RouterTransport.NamedPipe || transport == RouterTransport.Tcp)

    {

    this.MessageEncoding = MessageEncoding.Binary;

    }

    }

     

    public RouterTransport Transport

    {

    get { return this.transport; }

    set

    {

    this.transport = value;

    }

    }

    public MessageEncoding MessageEncoding

    {

    get { return this.messageEncoding; }

    set

    {

    this.messageEncoding = value;

    }

    }

     

    public HostNameComparisonMode HostNameComparisonMode

    {

    get { return this.tcpTransport.HostNameComparisonMode; }

    set

    {

    this.tcpTransport.HostNameComparisonMode = value;

    this.namedPipeTransport.HostNameComparisonMode = value;

    this.httpTransport.HostNameComparisonMode = value;

    }

    }

    public int ListenBacklog

    {

    get { return this.tcpTransport.ListenBacklog; }

    set { this.tcpTransport.ListenBacklog = value; }

    }

    public long MaxBufferPoolSize

    {

    get { return this.tcpTransport.MaxBufferPoolSize; }

    set

    {

    this.tcpTransport.MaxBufferPoolSize = value;

    this.namedPipeTransport.MaxBufferPoolSize = value;

    }

    }

    public int MaxBufferSize

    {

    get { return this.tcpTransport.MaxBufferSize; }

    set

    {

    this.tcpTransport.MaxBufferSize = value;

    this.namedPipeTransport.MaxBufferSize = value;

    }

    }

    public int MaxConnections

    {

    get { return this.tcpTransport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint; }

    set

    {

    this.tcpTransport.MaxPendingConnections = value;

    this.namedPipeTransport.MaxPendingConnections = value;

    this.tcpTransport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = value;

    this.namedPipeTransport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = value;

    }

    }

    public long MaxReceivedMessageSize

    {

    get { return this.tcpTransport.MaxReceivedMessageSize; }

    set

    {

    this.tcpTransport.MaxReceivedMessageSize = value;

    this.namedPipeTransport.MaxReceivedMessageSize = value;

    this.httpTransport.MaxReceivedMessageSize = value;

    }

    }

    public bool PortSharingEnabled

    {

    get { return this.tcpTransport.PortSharingEnabled; }

    set { this.tcpTransport.PortSharingEnabled = value; }

    }

    public TransferMode TransferMode

    {

    get { return this.tcpTransport.TransferMode; }

    set

    {

    this.tcpTransport.TransferMode = value;

    this.namedPipeTransport.TransferMode = value;

    this.httpTransport.TransferMode = value;

    }

    }

    bool IBindingRuntimePreferences.ReceiveSynchronously

    {

    get { return false; }

    }

    public override string Scheme

    {

    get { return this.TransportElement.Scheme; }

    }

    void Initialize()

    {

    this.httpTransport = new HttpTransportBindingElement();

    this.tcpTransport = new TcpTransportBindingElement();

    this.namedPipeTransport = new NamedPipeTransportBindingElement();

    this.textEncoding = new TextMessageEncodingBindingElement();

    //Added to support message Version

    this.textEncoding.MessageVersion = MessageVersion.Soap12WSAddressingAugust2004;

    //this.textEncoding.MessageVersion = MessageVersion.Soap11WSAddressingAugust2004;

    this.mtomEncoding = new MtomMessageEncodingBindingElement();

    this.binaryEncoding = new BinaryMessageEncodingBindingElement();

    this.binaryEncoding.MessageVersion = MessageVersion.Soap12WSAddressingAugust2004;

    //N.J. Switche to false for RM

    this.httpTransport.ManualAddressing = true;

    this.tcpTransport.ManualAddressing = true;

    this.namedPipeTransport.ManualAddressing = true;

    tcpTransport.MaxBufferSize = int.MaxValue;

    tcpTransport.MaxReceivedMessageSize = int.MaxValue;

    namedPipeTransport.MaxBufferSize = int.MaxValue;

    namedPipeTransport.MaxReceivedMessageSize = int.MaxValue;

    this.transport = RouterTransport.Http;

    this.messageEncoding = MessageEncoding.Text;

    }

    void ApplyConfiguration(string configurationName)

    {

    RouterBindingCollectionElement bindingCollectionElement = RouterBindingCollectionElement.GetBindingCollectionElement();

    RouterBindingElement element = bindingCollectionElement.Bindings[configurationName];

    if (element == null)

    {

    throw new ConfigurationErrorsException(string.Format("ConfigInvalidBindingConfigurationName", configurationName, bindingCollectionElement.BindingName));

    }

    else

    {

    element.ApplyConfiguration(this);

    }

    }

    TransportBindingElement TransportElement

    {

    get

    {

    switch (this.transport)

    {

    case RouterTransport.Http:

    return this.httpTransport;

    case RouterTransport.Tcp:

    return this.tcpTransport;

    case RouterTransport.NamedPipe:

    return this.namedPipeTransport;

    }

    return null;

    }

    }

    MessageEncodingBindingElement EncodingElement

    {

    get

    {

    switch (this.messageEncoding)

    {

    case MessageEncoding.Text:

    return this.textEncoding;

    case MessageEncoding.Mtom:

    return this.mtomEncoding;

    case MessageEncoding.Binary:

    return this.binaryEncoding;

    }

    return null;

    }

    }

    public override BindingElementCollection CreateBindingElements()

    {

    BindingElementCollection elements = new BindingElementCollection();

    elements.Add(this.EncodingElement);

    //N.J. Added support for reliable messaging

    //elements.Add(new ReliableSessionBindingElement());

    elements.Add(this.TransportElement);

    return elements;

    }

    }

     

     

    ******************************************Part of code that sends request to server:*******************************************

     

    public string SendMessage(Message message)

    {

    string response = "";

    //GO: support for tcp

    switch (_To.Uri.Scheme)

    {

    case "http":

    {

    IRequestReplyDatagramRouter forwardingChannel;

    ChannelFactory<IRequestReplyDatagramRouter> factory = new ChannelFactory<IRequestReplyDatagramRouter>(new RouterBinding(RouterTransport.Http), _To);

    // Add a channel behavior that will turn off validation of @mustUnderstand on the reply's headers.

    factory.Endpoint.Behaviors.Add(new MustUnderstandBehavior(false));

    forwardingChannel = factory.CreateChannel();

    //this.extension.RequestReplyDatagramChannels[to] = forwardingChannel;

    Console.WriteLine("Forwarding request " + message.Headers.Action + "...");

    Message responseMessage = forwardingChannel.ProcessMessage(message);

    response = MessageHelper.Serialize(responseMessage);

    break;

    }

    case "net.pipe":

    {

    ReturnMessageHandler returnMessageHandler = new ReturnMessageHandler();

    //TODO: Implementirati channel pool

    RouterBinding bind = new RouterBinding(RouterTransport.NamedPipe);

    ChannelFactory<IDuplexSessionRouter> factory = new DuplexChannelFactory<IDuplexSessionRouter>(new InstanceContext(null, returnMessageHandler), bind /*new RouterBinding(RouterTransport.NamedPipe)*/, _To);

    // Add a channel behavior that will turn off validation of @mustUnderstand on the headers belonging to messages flowing the opposite direction.

    factory.Endpoint.Behaviors.Add(new MustUnderstandBehavior(false));

    this.duplexSessionChannel = factory.CreateChannel();

    //GO: closing channels

    using (this.duplexSessionChannel as IDisposable)

    {

    this.duplexSessionChannel.ProcessMessage(message);

    }

    while (returnMessageHandler.ResponseMessage == null)

    {

    Thread.Sleep(1);

    }

    //System.Diagnostics.Trace.Write("Ivan: Router - dobio sam odgovor za poruku " + message.Headers.MessageId.ToString());

    response = returnMessageHandler.ResponseMessage;

    break;

    }

    case "net.tcp":

    {

    ReturnMessageHandler returnMessageHandler = new ReturnMessageHandler();

    //TODO: Implementirati channel pool

    ChannelFactory<IDuplexSessionRouter> factory = new DuplexChannelFactory<IDuplexSessionRouter>(new InstanceContext(null, returnMessageHandler), new RouterBinding(RouterTransport.Tcp), _To);

    // Add a channel behavior that will turn off validation of @mustUnderstand on the headers belonging to messages flowing the opposite direction.

    factory.Endpoint.Behaviors.Add(new MustUnderstandBehavior(false));

    this.duplexSessionChannel = factory.CreateChannel();

    //GO: closing channels

    using (this.duplexSessionChannel as IDisposable)

    {

    this.duplexSessionChannel.ProcessMessage(message);

    }

    while (returnMessageHandler.ResponseMessage == null)

    {

    Thread.Sleep(1);

    }

    //System.Diagnostics.Trace.Write("Ivan: Router - dobio sam odgovor za poruku " + message.Headers.MessageId.ToString());

    response = returnMessageHandler.ResponseMessage;

    break;

    }

    }

    GC.Collect();

    return response;

    }

     

     

    So as You can see maxbuffersize and maxreceivedmessagesize are int.MaxValue...

    Wednesday, August 15, 2007 7:28 AM
  • On the client side, after server sends a

    reply.

    Wednesday, August 15, 2007 7:30 AM
  • Generelly the pipe error indicate some kind of communication  issue.  I would suggest you to try with smaller message size and let me know if it works. Also try enabling the diagonistic tracing for the scenario. The tracing will provide better insight into what could be wrong here. for details refer http://msdn2.microsoft.com/en-us/library/ms733025.aspx.

    Also verify the application/System eventlog entries for any suspicious entry.

     

    -Jandeep

    Thursday, August 23, 2007 9:15 PM