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.

PipeServer crashing with many connections, IOException: 'Pipe is broken'

See original GitHub issue

Describe the bug

I have a program with a client that sends a message and waits for a response, and a server that waits for clients, and when one sends a message, the server sends a response.

Sometimes the server crashes when it tries to send a response with args.Connection.WriteAsync image

   at System.IO.Pipes.PipeStream.CheckWriteOperations()
   at System.IO.Pipes.PipeStream.Flush()
   at System.IO.Pipes.PipeStream.FlushAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at H.Pipes.IO.PipeStreamWriter.<WriteAsync>d__8.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at H.Pipes.IO.PipeStreamWrapper.<WriteAsync>d__17.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at H.Pipes.PipeConnection`1.<WriteAsync>d__38.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Program.<>c.<<<Main>$>b__0_2>d.MoveNext() in C:\Users\Erez\source\repos\HPipeMultiClient\Server\Server.cs:line 21

Happens when running the server in debug from Visual Studio. Doesn’t happen when running the server from console.

Steps to reproduce the bug

  1. In Visual Studio 2022, Open this minimal solution that reproduces the problem: https://github.com/erezwanderman/HPipeMultiClient
  2. Build the solution and start debugging (the Server project)
  3. Start Client.exe outside of Visual Studio
  4. Watch the server crash on line 21

server.MessageReceived += async (sender, args) => { Console.WriteLine($“Client {args.Connection.PipeName} says: {args.Message}”); var response = new Message { Response = args.Message!.Request + args.Message!.Request }; Console.WriteLine($“Sending to {args.Connection.PipeName}: {response}”); await args.Connection.WriteAsync(response); };

Expected behavior

No crash, send message successfully

Screenshots

image

NuGet package version

2.0.37

Platform

Console

IDE

Visual Studio 2022

Additional context

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
HavenDVcommented, Jun 2, 2022

I have released a new version with a suggested fix, please check it out. The ideal situation would be if you could write a test that fails in the version of the library before this fix, so that the situation does not happen again and I do not miss anything.

0reactions
HavenDVcommented, Aug 14, 2022

Replace Task.WaitAll(tasks); to await Task.WhenAll(tasks);.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Reconnecting to a NamedPipeServerStream after ...
They successfully connect and send data back and forth for some length of time. Then, unexpectedly, appClient crashes. The user relaunches it ...
Read more >
Issues · HavenDV/H.Pipes
Feature request: Have a connection identifier on the server based on a ... PipeServer crashing with many connections, IOException: 'Pipe is broken' bug ......
Read more >
System.IO.IOException: Pipe is broken - Discussions
Pipes.NamedPipeServerStream.BeginWaitForConnection(AsyncCallback ... The Mimecast for Outlook plugin specifically crashes and provides logs ...
Read more >
Java IO Ioexception Broken Pipe: Reasons and Fixes
The java IO ioexception broken pipe error occurs when a socket connection is closed while it is still being used to send or...
Read more >
"failed: Broken pipe" error crashing the server
Our server however crashes sometimes for a unknown reason. ... Broken pipe, means that something closed the connection in an uncontrolled ...
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