Search code examples
blazorblazor-server-side

Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'


I get this below error message on Blazor server app when I try to send images over 50KB

Error: Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'

I am using a richtext box and when I paste an image on it over 50KB I am getting this error. The error is happening on Blazor.server.js. This issue must be related to the data limit that can be send over web socket however even after I update this limit to larger size, I still see this issue.

This is my startup file code where I have modified the limit.

 app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapBlazorHub(options =>
                {
                    **options.ApplicationMaxBufferSize = 10 * 1024 * 1024;
                    options.TransportMaxBufferSize = 10 * 1024 * 1024;**
                });
                endpoints.MapFallbackToPage("/_Host");
            });

The error is happening on blazer.server.js and the connection is getting dropped eachtime it is happening. Has any one faced this issue with Blazor server enter image description here


Solution

  • I have increased the size for Singal R and that fixed the issue for now but this is not a proper solution.

    services.AddSignalR(e => {
                    e.MaximumReceiveMessageSize = 102400000;
                });
    

    The proper solution is to implement your own hub between client and server and process in chunks and stick it together.

    refer to : https://learn.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-3.1