none
Named Pipe De/Re-Construction RRS feed

  • Question

  • I have built a VB.NET application, two instances of which talk (only) to each other via a single named pipe.

    One instance is configured as named pipe Server, and the other as Client.

    Works fine, except that once I break the pipe (such as by stopping either the Client or the Server), I am unable to re-establish it.

    I have tried everything I can find to "destroy" the pipe and associated objects, but keep getting "All pipe instances are busy" when trying to re-create it, so I am missing something.

    Is there a way to destroy the pipe so that the application can re-create it as if it was just starting up?

    Thanks in advance for any help/insight!

    Thursday, December 31, 2015 9:15 PM

All replies

  • Hi RomT,

    >>Is there a way to destroy the pipe so that the application can re-create it as if it was just starting up?

    The short answer is no.  In the .NET Framework, we implement named pipes by using the NamedPipeServerStream and NamedPipeClientStream classes. As we know, both the two classes inherited from Stream class. We can't re-use the stream after we close it.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 1, 2016 2:12 AM
    Moderator
  • I suppose the original poster wants to reuse the name of the named pipe and create a new NamedPipeServerStream or NamedPipeClientStream object for it, rather than reuse those objects.

    What is the value of the maxNumberOfServerInstances parameter of the NamedPipeServerStream constructor? If it is 1 and the server is restarted and the client doesn't close its end of the pipe instance quickly enough, perhaps the client prevents the pipe instance from being deleted and the server then cannot create a new instance because the limit is already full.

    • Proposed as answer by Kristin Xie Wednesday, January 6, 2016 3:03 AM
    Monday, January 4, 2016 8:10 PM
  • Thanks!

    What if I created a separate process to wrap the NamedPipeServer/ClientStream objects, then killed/destroyed the process?  Would the stream be "re-creatable" then (able to use the same pipe name) from another new/separate process?

    Or, perhaps I could set up some way for the application instance pair to "agree" on a new pipename, abandoning the old one; perhaps an ini/config file with a set of names, using the next one in the list each time the pipe breaks.  I know that really sounds like a hack, but this really needs to happen even if I have to shut down the application and auto-start it.

    Thursday, January 7, 2016 8:41 PM
  • Or, perhaps I could set up some way for the application instance pair to "agree" on a new pipename, abandoning the old one;

    I suggest you created a new name. Why do you want to use the same name?
    Friday, January 8, 2016 9:53 AM
  • I don't think separate processes would improve the situation at all. Try changing the maxNumberOfServerInstances parameter. If you use NamedPipeServerStream.MaxAllowedServerInstances and still get the same problem, then you'll know the reason is somewhere else.
    Friday, January 8, 2016 2:59 PM