Server side blazor Microsoft.JSInterop/SignalR exception when passing large strings
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
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>();
thank you!
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");
});
Take a look at MaximumReceiveMessageSize https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&tabs=dotnet#configure-server-options
Thanks, it works!