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

Blazor server-side: Accumulated SignalR messages hits IIS 30Mb limit #13470

Tewr opened this issue Aug 27, 2019 · 4 comments


Copy link

commented Aug 27, 2019

Describe the bug

When using Server-side blazor and IIS hosting, the IIS 30Mb upload limit is reached after a certain amount of interop messages (I'd guess, around 30Mb :P)

This problem is limited to the use of WebSockets under IIS, if SignalR fallbacks to XHR, there is no problem.

To Reproduce

Steps to reproduce the behavior:

  1. Using 3.0.100-preview8-013656 / VS 19 16.3 Preview 2
  2. Create a new Blazor server-side project.
    Paste the following code in index.razor:
@page "/"
@inject IJSRuntime js
<h1>IIS "Request body too large" reproduction</h1>

<button @onclick="IISProblem">Click here to launch the test</button>

@code {
    string output = "";
    public async Task IISProblem()
        // Create a js method that echoes data
        await js.InvokeAsync<string>("eval", "window.t = function(s) { return s ; }");

        output += $"Creating big string...{Environment.NewLine}";
        // Create a string that passes the defsault signalR limit
        var largeString = data;
        while (System.Text.ASCIIEncoding.ASCII.GetByteCount(largeString + data) < 30768)
            largeString += data;

        output += $"Transferring ({System.Text.ASCIIEncoding.ASCII.GetByteCount(largeString)} bytes) string back and forth...{Environment.NewLine}";

        var bugAppearsAtLeastAt = (40 * 1024 * 1024);
        for (var i = 0; i < (bugAppearsAtLeastAt / 30768) ; i++)
            var p = await js.InvokeAsync<string>("t", largeString);
            var x = p;

        output += $"Success! bug not reproduced!";
  1. Launch using default config (IIS Express), click the button
  2. See error:
Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer: Error: Unexpected exception in "IISHttpContext.ReadBody".

Microsoft.AspNetCore.Server.IIS.BadHttpRequestException: Request body too large.
   at Microsoft.AspNetCore.Server.IIS.BadHttpRequestException.Throw(RequestRejectionReason reason)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.ReadBody()
Microsoft.AspNetCore.SignalR.HubConnectionHandler: Error: Error when processing requests.

System.IO.InvalidDataException: Connection terminated while reading a message.
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.DispatchMessagesAsync(HubConnectionContext connection)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)
Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint '/_blazor'

Expected behavior

The text "Success! bug not reproduced!" appears.


If applicable, add screenshots to help explain your problem.

Additional context

The problem can also be reproduced with IIS (rather than IIS express).

I have not been able to work around this using the following in web.config:

          <requestLimits maxAllowedContentLength="1048576000" />


  1. If the following is added to Startup.cs, it avoids the problem:
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            app.Use(async (context, next) =>
                    .MaxRequestBodySize = null; // setting this to a number will just postpone the bug until that limit has reached (i.e 50Mb will still break after three pushes of the button in the example above)

                await next.Invoke();
  1. Use Kestrel - OK
  2. Use IIS Without websockets (Falls back to XHR) - OK

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\

Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc

.NET Core SDKs installed:
1.1.13 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.600-preview-009472 [C:\Program Files\dotnet\sdk]
2.1.600-preview-009497 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.0.100-preview-009812 [C:\Program Files\dotnet\sdk]
3.0.100-preview-010184 [C:\Program Files\dotnet\sdk]
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview-18579-0056 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview-27122-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview-27324-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-alpha-27128-4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.0.0-preview-27325-3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]


This comment has been minimized.

Copy link

commented Aug 27, 2019

@jkotalik @Tratcher Looks like a regression in 3.0 caused by #9475 where upgraded requests have the max request limit applied to them when it shouldn't.

@Pilchie This effectively makes WebSockets with IIS useless, we should definitely fix it for 3.0.


This comment has been minimized.

Copy link

commented Aug 27, 2019

@BrennanConroy is there a PR with the fix I can take to Tactics this morning? It's likely too late for Preview 9, but target release/3.0?


This comment has been minimized.

Copy link

commented Aug 27, 2019

I've started a PR at #13477

Currently testing it locally and with Helix. The fix is commented out in the PR right now.


This comment has been minimized.

Copy link

commented Aug 27, 2019

Thanks for the report @Tewr!

This will be fixed in 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.