Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8988175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:57:44+00:00 2026-06-15T21:57:44+00:00

I am having stability issues using a named pipe for communication between a C#

  • 0

I am having stability issues using a named pipe for communication between a C# and Java app.

Here is the code that sets up the named pipe in C# and reads lines of XML strings.

try
{
    NamedPipeServerStream inStream = new NamedPipeServerStream(inName, PipeDirection.In);
    inStream.WaitForConnection();
    reader = new StreamReader(inStream);
    while (!Stopped && !reader.EndOfStream)
    {
        string xml = reader.ReadLine();
        processXml(xml);
    }
}
catch (Exception e)
{
    log.Error("Error in receiver", e);
}
finally
{
    log.Info("Receiver ended");
}

And here is the connection and write code in Java

public void connect() throws TransportUnavailableException
{
    try
    {
        File inPipe = new File(inName);
        os = new FileOutputStream(inPipe);
        // Uses JAXB for XML serialization
        marshaller = context.createMarshaller();
    }
    catch (FileNotFoundException e)
    {
        throw new TransportUnavailableException("Named pipe not found: " + inName);
    }
}

public void send(Message message)
{
    marshaller.marshal(message, os);
    os.write('\n');
    os.flush();
}

Everything works fine normally. But many users are reporting crashes. I don’t see any exceptions in logs that suggest a reason for the pipe dying. I just see that the receiving thread in C# ends (i.e. ‘Receiver ended’ in the logs) and after this I get an IO exception on the next attempted send from Java with a message ‘The handle is invalid’. This seems to happen randomly, but usually within the 1st minute or 2 after the connection was established. The pipe ending message also happens when the application is not doing anything, it could have been minutes since the last user operation. Then it could be a few more minutes before the next write is attempted from Java.

All reasons for my app to bring down the pipe on purpose (e.g. a crash elsewhere in system) are logged and I never see that as a reason for the pipe ended, I just get the message that the reader has given up reading.

  • Could there be any external reason for the pipe being killed, anti-virus, firewall etc?
  • I noticed I didn’t use a RandomAccessFile from Java like most examples seem to use. Could this be a reason?

Any help/suggestion appreciated
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:57:45+00:00Added an answer on June 15, 2026 at 9:57 pm

    Your server side code only processes one connection, then it exits when it reads to EOS. You need to create the named pipe, loop accepting connections, and spin up a new thread to handle each connection. You also need to close each connection when you’re finished with it.

    However I would use TCP rather than named pipes for this, for several reasons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a weird problem here. Everybody knows that if you use web.config's customErrors section
Having trouble with each function... Will try to explain by example... In my code,
Having a hard time with labels on a ggplot2 plot. Here's a similar plot
Having trouble accessing javascript code in a mixed html/js ajax response. jQuery ajax doc
Having had some Sql Compact db corruption issues in the past and gone through
Having a bizarre issue that I'm hoping people can shed some like on. When
Having just upgraded to iOS 4.1 (Xcode 3.2.4) I am getting warnings when using
Having a weird issue. I'm new to Macs and have a windows VM that
Having an issue, here is the problem. Created a branch from the trunk, made
Having problems with out of scope for NSDate in an iphone app. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.