aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Server side blazor Microsoft.JSInterop/SignalR exception when passing large strings

Open Kaffeegangster opened this issue 8 years ago • 5 comments

passing or returning a string>32k with Microsoft.JSInterop throws an exception and closes SignalR connection. Do i need to implement some kind of argument chunking ? Is the blazor serialisation buffersize configurable?

Microsoft.AspNetCore.SignalR.HubConnectionHandler:Error: Error when processing requests.

System.InvalidOperationException: Advancing examined to the end would cause pipe to deadlock because FlushAsync is waiting. at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_BackpressureDeadlock() at System.IO.Pipelines.Pipe.AdvanceReader(BufferSegment consumedSegment, Int32 consumedIndex, BufferSegment examinedSegment, Int32 examinedIndex) at System.IO.Pipelines.Pipe.AdvanceReader(SequencePosition& consumed, SequencePosition& examined) at System.IO.Pipelines.Pipe.DefaultPipeReader.AdvanceTo(SequencePosition consumed, SequencePosition examined) at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.DispatchMessagesAsync(HubConnectionContext connection) at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.RunHubAsync(HubConnectionContext connection) Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 11613.7288ms 101

Kaffeegangster avatar Oct 25 '18 16:10 Kaffeegangster

You're hitting the default buffer size limit in SignalR. The error message isn't great, but there is an issue to address that. If you want to increase the buffer size you can do that by replacing the call to app.UseServerSideBlazor<App.Startup>() with:

            app.UseSignalR(route => route.MapHub<BlazorHub>(BlazorHub.DefaultPath, o =>
            {
                o.ApplicationMaxBufferSize = 131072; // larger size
                o.TransportMaxBufferSize = 131072; // larger size
            }));
            app.UseBlazor<App.Startup>();

danroth27 avatar Oct 29 '18 16:10 danroth27

thank you!

Kaffeegangster avatar Oct 31 '18 10:10 Kaffeegangster

Is there any workaround for this using .net core 3.0 ? I tried something like below, but it is not working:

app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(o => { o.ApplicationMaxBufferSize = 92233720; // larger size o.TransportMaxBufferSize = 92233720; // larger size });

                           endpoints.MapFallbackToPage("/_Host");
        });

Styx8888 avatar Nov 28 '19 08:11 Styx8888

Take a look at MaximumReceiveMessageSize https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&tabs=dotnet#configure-server-options

BrennanConroy avatar Dec 02 '19 16:12 BrennanConroy

Thanks, it works!

Styx8888 avatar Dec 03 '19 08:12 Styx8888