dotnet / dotnet/aspnetcore

Add additional logic in the InputFile component to split the upload manifest into multiple messages if it exceeds the buffer size for a single SingalR message

Open
#42,993 6 comments 0 reactions 0 assignees View on GitHub
area-blazor bug feature-blazor-server Pillar: Technical Debt Priority:2
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

There seems to be a correlation between InputFile upload limit and SignalR MaximumReceiveMessageSize property in Blazor Server Side projects. This has not been described in the documentation for Blazor file uploads: [https://docs.microsoft.com/en-us/aspnet/core/blazor/file-uploads](url)

Run the code and select multiple files that are somewhere between 64-200 MB in total. On my system I have not found reason as to why it would sometimes work with up to 200 MB but in some cases it will disconnect with just over 64MB of files in total. Without changing the MaximumReceiveMessageSize property the connection to the server will be lost and on OnChange method is never called whenever it reconnects. The console has a lost connection message but that's it, nothing in the VS runtime logs.

_Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'.
e.log @ blazor.server.js:1_

However if you change the MaximumReceiveMessageSize property from 32KB to something higher it will start to accept files with a total size that goes beyond 200 MB (or whatever the limitation is for a given test).

If this is not a bug then there should some documentation or an explanation as to what is the relationship between total up-loadable file size limit and SignalR message buffer size. Is all the file info being communicated to the server in one large message and if it hits the default 32KB limit it fails?

The two issues from 2019 touch on the subject but do not have the reasoning on how the buffer size is related to file count or size:
[https://github.com/dotnet/aspnetcore/issues/11643](url)
[https://github.com/dotnet/aspnetcore/issues/12203](url)

### Expected Behavior

The expected behaviour is to control file count and size limits with the two parameters below. If SignalR buffer size is involved it should be clearly detailed that it also plays a role in file upload scenarios.

```
InputFileChangeEventArgs.GetMultipleFiles(maximumFileCount);
IBrowserFile.OpenReadStream(maxAllowedSize);
```

### Steps To Reproduce

```
@page "/"

File Upload

@if (Files != null)
{
foreach(var file in Files)
{

@file


}
}

@code {
const int MaxUploadFiles = 1000;
private IEnumerable Files;
protected void SelectFiles(InputFileChangeEventArgs e)
{
Files = e.GetMultipleFiles(MaxUploadFiles).Select(f => f.Name);
}
}
```

### Exceptions (if any)

Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'.
e.log @ blazor.server.js:1

### .NET Version

6.0.302

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the InputFile component and its handling of upload manifests, then review how SignalR message-size limits affect the reproduction shown in the issue. Verify the behavior with multiple large files and the listed GetMultipleFiles and OpenReadStream settings. Done means the upload no longer depends on a single oversized SignalR message, or the relationship is clearly documented if implementation is not appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.