Connection Closed Error and Attempting to Reconnect
Editor for Blazor,
FileManager for Blazor,
FileSelect for Blazor,
PdfViewer for Blazor
This article is relevant to different scenarios and Telerik Blazor components. Here are a few examples:
- Pasted images inside the Editor are discarded. They are not converted to base64 and not saved to the database.
- Pasting large images or large data always drops the Blazor app SignalR connection. The browser console shows "Attempting to reconnect" message and I have to reload the page.
- Large HTML content in the Editor restarts the Blazor app connection.
- The Editor freezes when copying and pasting long text.
- An error shows when the Editor contains a large document and the HTML string has lot of characters.
- The FileSelect
OnSelecthandler fails on
- FileSelect upload scenarios break with large files. The
Streamhas no data.
Streamto a new
MemoryStream. There is no error message.
- Files are written to the server directory with a size of zero bytes.
FileSelectFileInfo.Stream.CopyToAsyncmethod hangs. Execution stops and no exception is thrown. The next line in the code is never reached. I am attempting to load a JPG image into the MemoryStream.
The PDF Viewer doesn't display PDF files, which are assigned to its
Data parameter, but it displays local files from the user device.
Cannot import XSLX files which have a lot of records. It works for few records. It's a random behaviour.
The exceptions may be similar to:
Connection disconnected with error 'Error: Server returned an error on close: Connection closed with an error.'
Attempting to reconnect to the server...
A task was canceled.
Blazor Server apps use a SignalR WebSocket to communicate between the client (browser) and server. The SignalR WebSocket has a default maximum message size of 32 KB. A large Editor
Value, FileSelect file size, or a PDFViewer
Data can exceed the maximum SignalR message size, which will close the connection and abort the current application task.
Make sure that
AddServerSideBlazor() is called only once. All configuration settings in
AddCircuitOptions must go together with this single statement.