Server connection problem on a blazor site

Saeed Pooladzadeh 251 Reputation points
2025-01-04T20:52:03.84+00:00

Hi,

I have made this app in blazor:

Index

Occasionally, I encounter this error: "Attempting to connect to the server." Do you know how to solve it?

regards,

Saeed

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,645 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,561 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 69,121 Reputation points
    2025-01-04T21:29:34.14+00:00

    This error is from Blazor server. the client code uses signal/r (a persistent connection) to talk to the server. The error means the signal/r connection was broken and the client code needs to reconnect. This could caused by either be a server recycle or crash, or unreliable internet connection (say mobile). Check your server logs.

    another cause is if the tab hosting the blazor app is not the active tab for a period of time, then the browser will kill the connection.

    0 comments No comments

  2. Brando Zhang-MSFT 3,876 Reputation points Microsoft Vendor
    2025-01-06T03:06:44.06+00:00

    Hi @Saeed Pooladzadeh,

    This may happen after a period of inactivity for your application, it will show the message "Attempting to reconnect to server...".

    If you are using blazor 7, 8 or previous version, I suggest you could consider upgrading the version to the 9.

    According to this article, you could find:

    • When the user navigates back to an app with a disconnected circuit, reconnection is attempted immediately rather than waiting for the duration of the next reconnect interval. This improves the user experience when navigating to an app in a browser tab that has gone to sleep.
    • When a reconnection attempt reaches the server but the server has already released the circuit, a page refresh occurs automatically. This prevents the user from having to manually refresh the page if it's likely going to result in a successful reconnection.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Brando

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.