question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The server stops working

See original GitHub issue

Describe the bug

I am looking for a reliable named pipes server for communication between C ++ and C #. Unfortunately, the H.Pipes server can easily crash due to an error in the client. Here’s an example code that shows how to make the server stop responding to new connections:

Steps to reproduce the bug

  1. Run ConsoleApp from samples as server
  2. Connect to server by the following code:
using System;
using System.IO.Pipes;
using System.Net;
using System.Threading;

namespace HPipeError
{
  internal class Program
  {
    private static void Main(string[] args)
    {
      var pipeClient = new NamedPipeClientStream("named_pipe_test_server");
      while (!pipeClient.IsConnected)
      {
        pipeClient.Connect();
        Thread.Sleep(100);
      }
      // read string length
      var buffer = new byte[sizeof(int)];
      pipeClient.Read(buffer, 0, sizeof(int));
      var len = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(buffer, 0));
      // read string content
      buffer = new byte[len];
      pipeClient.Read(buffer, 0, len);
    }
  }
}
  1. After executing this code, try to connect to the server (e.g. using SampleApp as a client). It will be impossible.

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Platform

No response

IDE

No response

Additional context

Why is this happening?

After establishing the connection by the client, the server sends the name of the pipe created for the client through the main pipe. The server then waits for the client to establish a connection to the newly created pipe, but unfortunately the main pipe is closed. If the client fails to connect, the main pipe will not be recreated and you will not be able to connect to the server anymore. So one malfunctioning client can therefore block the server.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
HavenDVcommented, Aug 16, 2023

For now I added a test for this case and confirmed the issue.

2reactions
HavenDVcommented, Aug 16, 2023

Thanks for bringing this up. I will take a look now

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix "DNS Server Not Responding" Error (11 Methods)
Possible fixes include restarting your router or modem, checking for network issues, and updating your browser. DNS servers play an essential ...
Read more >
How to the Fix "DNS Server Not Responding" Error
“DNS Server Not Responding” means that your browser was unable to establish a connection to the internet. Typically, DNS errors are caused ...
Read more >
What does it mean when it says the server stopped responding?
When it says the server stopped responding, it means that the server is no longer able to accept and process requests from the...
Read more >
3 Ways To Fix Safari When the Server Stopped Responding
1. Verify you have a working internet · 2. Verify you have the correct address · 3. Clear the browser cache.
Read more >
How do I fix a server that is not responding?
1. Check the network connection: Make sure that your server is properly connected to the network and that there are no issues with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found