H.Pipes icon indicating copy to clipboard operation
H.Pipes copied to clipboard

Large messages on .NET 6 fail to send

Open checkymander opened this issue 2 years ago • 9 comments

Describe the bug

When transferring messages larger than 65535 bytes on .NET 6 the server throws an exception stating

Expected <number of sent> bytes but read 65536

Steps to reproduce the bug

Send the contents of a 1MB file over the channel and catch the exception

Same issue whether I send a serializable object or a standard string

Expected behavior

No response

Screenshots

No response

NuGet package version

No response

Platform

Console

IDE

Visual Studio 2022

Additional context

Seems to be related to this: https://github.com/HavenDV/H.Pipes/blob/9299ffd93b5518a7c06e7fe12529bf45dfd8809c/src/libs/H.Pipes/IO/PipeStreamReader.cs#L72

checkymander avatar May 24 '22 18:05 checkymander

This is on the base H.Pipes library, with no formatter libraries installed/in-use

checkymander avatar May 24 '22 18:05 checkymander

Are you using Windows or another OS?

HavenDV avatar May 25 '22 04:05 HavenDV

Windows 11

checkymander avatar May 25 '22 15:05 checkymander

This is rather odd given that our tests are run on Windows and include cases where there is a 1MB data transfer. My local tests on Windows 11 also complete gracefully. Perhaps some additional conditions are required for the problem to manifest itself?

HavenDV avatar May 27 '22 23:05 HavenDV

This is the sendcode I use


DelegateMessage dm;

IEnumerable<string> parts = json.SplitByLength(50000);

foreach (string part in parts)
{
    if (part == parts.Last())
    {
        dm = new DelegateMessage()
        {
            uuid = message.uuid,
            message = part,
            final = true
        };
    }
    else
    {
        dm = new DelegateMessage()
        {
            uuid = message.uuid,
            message = part,
            final = false
        };
    }
    await this.serverPipe.WriteAsync(dm);
}

This is after I implemented chunking to work around my issue. Previously it was just one message, which was the contents of a 50MB file encoded in base64

await this.serverPipe.WriteAsync(dm);

The pipe server is just set to

this.serverPipe = new PipeServer<DelegateMessage>("mypipe");

checkymander avatar May 27 '22 23:05 checkymander

Clarification, this happens when used on a local network. When transferring between computers. I have to divide the data into chunks through my add-on, and then collect it back on the other side.

Yakonrus avatar Aug 13 '22 08:08 Yakonrus

Most likely fixed in the latest update.

HavenDV avatar May 25 '23 21:05 HavenDV

sweet I'll try it out!

checkymander avatar May 26 '23 02:05 checkymander

this looks like a limit of 64kb beyond this, more data transfer is not guaranteed from the OS side

rahul-dutt-sharma avatar Jun 20 '23 13:06 rahul-dutt-sharma