Comments (13)
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.
from h.pipes.
I remember having some problems with Debug when I didn't use H.Pipes.AccessControl for the server. Are you using it? In particular server.AllowUsersReadWrite();
from h.pipes.
Yes, I used H.Formatters.MessagePack & H.Pipes.AccessControl in the original program but not in this reproduction example.
Now added them in a new branch: https://github.com/erezwanderman/HPipeMultiClient/tree/MessagePack%26AccessControl.
It does not change behaviour. still crashing.
from h.pipes.
After analyzing it furthuer, I think that in IO/PipeStreamWriter.cs, PipeStreamWriter.WriteAsync, the call BaseStream.WriteAsync sends the response, and sometimes the client is fast enough to quickly disconnect before the server finishes flushing and draining, and then the server throws exception on flushing or draining.
It can be avoided by catching and ignoring in
PipeStreamWriter.cs call "await BaseStream.FlushAsync(cancellationToken).ConfigureAwait(false);"
PipeStreamWrapper.cs call "Writer.WaitForPipeDrain()"
I think this Stack Overflow question and answer addresses this exact problem.
Idea for solution: have a closing-handshake. When calling DisconnectAsync or DisposeAsync on PipeClient, do not disconnect but rather send a message to the server to disconnect. And then the server will disconnect.
from h.pipes.
Thanks! This fixes the issue and now the program works without exceptions.
from h.pipes.
Hi, I'm evaluating some c# Named Pipes nugets and while testing this one I encountered this "Pipe is broken" problem, perhaps in a little bit different way but none the less.
I started the ConsoleApp sample and used a SysInternals tool called accesschk.exe to check what it reports. Upon doing so I can't catch any exceptions, but the pipe server stops working after a single calling like this
accesschk.exe \pipe\named_pipe_test_server
The tool prints a list of permissions set on the pipe and then very quickly disconnects. Perhaps this tool can be used to find out what happens in H.Pipe, and perhaps prevent the pipeserver from stop serving clients. I find it very useful to check that running pipeservers do have the right permissions. Unfortunately meny named pipe implementations fail to handle this tools rather crude behaviour.
This nuget seams to be a very nice package, thank you!
from h.pipes.
The problem is computer related.
I have a client server application.
On the server - 4 PipeServers.
I'm running 17 client applications on same laptop, each with 4 PipeClient.
On i7 10870H it works more or less.
On i5 4210U - permanent IOException: 'Pipe is broken'
CPU usage is very high.
from h.pipes.
The problem is computer related. I have a client server application. On the server - 4 PipeServers. I'm running 17 client applications on same laptop, each with 4 PipeClient. On i7 10870H it works more or less. On i5 4210U - permanent IOException: 'Pipe is broken' CPU usage is very high.
Just to be sure - are your clients and servers console applications?
from h.pipes.
No, .NET 6, WPF
And this is a highly loaded application. Therefore, perhaps on a weak computer it becomes noticeable.
from h.pipes.
I will write tests for high-load situations when I have free time.
You can speed up this process if you wish. Submitting a PR with a test that will work on both of your computers will greatly speed up the fix for this issue. You can take these tests as a basis, run several copies in parallel, generating names for the pipes:
https://github.com/HavenDV/H.Pipes/blob/master/src/tests/H.Pipes.Tests/DataTests.cs
from h.pipes.
The problem is that I have to isolate the Canon EDSDK dll, the only option was to run a separate client for each camera.
I am using modified: https://github.com/acdvorak/named-pipe-wrapper
There are problems here too.
0x800705AA insufficient system resource
I decided to find another solution. I tried your library.
I'll check later.
from h.pipes.
Wanted so to follow a lot of connections.
But for some reason even one client does not connect.
What am I doing wrong?
[TestMethod]
public async Task TypeTest()
{
using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(1));
var completionSource = new TaskCompletionSource<bool>(false);
using var registration = cancellationTokenSource.Token.Register(() => completionSource.TrySetCanceled());
var formatter = new BinaryFormatter();
const string pipeName = "data_test_pipe";
await using var server = new PipeServer<byte[]>(pipeName, formatter);
server.ExceptionOccurred += (_, args) => Assert.Fail(args.Exception.ToString());
server.MessageReceived += (_, args) =>
{
Console.WriteLine($"MessageReceived: {args.Message[0]}");
completionSource.TrySetResult(true);
};
await server.StartAsync(cancellationTokenSource.Token);
Task[] tasks = new Task[1];
for (int j = 0; j < tasks.Length; j++)
{
int i = j;
tasks[i] = Multi(i, pipeName);
}
Task.WaitAll(tasks);
Assert.IsTrue(await completionSource.Task);
}
private async Task Multi(int i, string pipeName)
{
using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(1));
var formatter = new BinaryFormatter();
await using var client = new PipeClient<byte[]>(pipeName, formatter: formatter);
client.ExceptionOccurred += (_, args) => Assert.Fail(args.Exception.ToString());
await client.ConnectAsync(cancellationTokenSource.Token);
byte[] bytes = new byte[1024 * 1024];
bytes[0] = (byte)(i+1);
await client.WriteAsync(bytes, cancellationTokenSource.Token);
}
from h.pipes.
Replace Task.WaitAll(tasks);
to await Task.WhenAll(tasks);
.
from h.pipes.
Related Issues (20)
- Feature request: Have a connection identifier on the server based on a client connection HOT 3
- Application getting terminated HOT 5
- The server stops working HOT 8
- Feature request: Support CreatePipeStreamFunc on the client as well
- Handles are not disposed HOT 1
- Implementation questions HOT 1
- Different Send and Receive Types Info Request HOT 1
- Compiler Errors: Tests, 4.8
- .NET 8 support HOT 2
- Does this library support read-only or write-only? HOT 11
- ConsoleApp sample server generates an exception with .NET 8.0 HOT 3
- Couldn't send data in specflow testing application via pipes
- Cannot access a disposed object. HOT 3
- I am getting below issue when i am communicating from .net framework app to .net 7 HOT 6
- MessagePack Unions not serialized correctly. HOT 2
- Security question(s) regarding BinaryFormatter HOT 6
- Explore possibility to use DataFlow Task Parallel library
- Exception in IPC call HOT 3
- MemoryPack support HOT 2
- Memory Leak in H.Pipes Client’s WriteAsync Method HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h.pipes.