Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.BeginSendFile throws SocketException "The parameter is incorrect" when sending large files #41834

Closed
vsfeedback opened this issue Sep 3, 2020 · 6 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


Socket.BeginSendFile throws a socket exception System.Net.Sockets.SocketException: 'The parameter is incorrect'
when trying to send files more than 3.5 GB, however files less than 1.5 GB was sent without problems.

To reproduce the issue :

1. Create a TCP socket.
2. Connect the socket to the remote endpoint.
3. Send a 3.5 GB file using Socket.BeginSendFile(String, AsyncCallback, Object)

Tested on both 2004 and 1809 Windows 10 builds and same exception was thrown.

To help reproducing the issue the code can be found here.


Original Comments

Feedback Bot on 8/17/2020, 01:12 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net.Sockets untriaged New issue has not been triaged by the area owner labels Sep 3, 2020
@ghost
Copy link

ghost commented Sep 3, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@scalablecory
Copy link
Contributor

Can you please confirm that this happens on .NET Core 3.x or with a .NET 5 preview?

@scalablecory scalablecory removed the untriaged New issue has not been triaged by the area owner label Sep 4, 2020
@scalablecory scalablecory added this to the Future milestone Sep 4, 2020
@RishoT17
Copy link

RishoT17 commented Aug 3, 2021

It's happening for me on ASP.Net Core 5

@wfurt
Copy link
Member

wfurt commented Aug 3, 2021

Seems like dup of #42534
There was also some more discussion about OS limit here: #41906 and it seems like this is OS limitation.

@RishoT17
Copy link

RishoT17 commented Aug 3, 2021

Yeah, I've found the same thing, according to my research, it's using TransmitFile underneath, which has the 2GB limitation.
Sources:
https://stackoverflow.com/questions/44745529/socket-sendfile-send-big-file-error-87
https://docs.microsoft.com/en-gb/windows/win32/api/mswsock/nf-mswsock-transmitfile?redirectedfrom=MSDN

One workaround I've found is to use the DotNetZip NuGet package to compress and split the big file into smaller ones before sending. This package can do the splitZip with a custom maxOutputSegmentSize:

            int segmentsCreated;
            using (ZipFile zip = new ZipFile())
            {
                zip.AddDirectory(filePath);
                zip.MaxOutputSegmentSize = int.MaxValue;
                zip.Save(zipPath);

                segmentsCreated = zip.NumberOfSegmentsForMostRecentSave;
            }

@wfurt
Copy link
Member

wfurt commented Dec 15, 2022

closing as dup of #42534.

@wfurt wfurt closed this as completed Dec 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jan 14, 2023
@karelz karelz modified the milestones: Future, 8.0.0 Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants