Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

blazor Server timeout while debugging

Tags:

c#

blazor

If I debug my code for more than 30 seconds, the web page shows

"Attempting to reconnect to the server: # of 8"

and dev console message is

"Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server".

Is there any setting that can disable timeout or at least make it way longer than it is now?

like image 861
joke labs Avatar asked Oct 25 '25 09:10

joke labs


2 Answers

In case you use long polling you need to add also this configuration option:

app.UseEndpoints(endpoints =>
    // other settings go here
    endpoints.MapBlazorHub(options => {
        options.WebSockets.CloseTimeout = new TimeSpan(1, 1, 1);
        options.LongPolling.PollTimeout = new TimeSpan(1, 0, 0);
    })
);
like image 90
Nicola Biada Avatar answered Oct 27 '25 00:10

Nicola Biada


Modify the _Host.cshtml file (or _Layout.cshtml in ASP.NET 6):

<environment include="Development">
  <script src="_framework/blazor.server.js" autostart="false"></script>
  <script>
    Blazor.start({
      configureSignalR: function (builder)
      {
        let c = builder.build();
        c.serverTimeoutInMilliseconds = 9999999;
        builder.build = () => c;
      }});
  </script>
</environment>
<environment exclude="Development">
  <script src="_framework/blazor.server.js"></script>
</environment>
like image 27
palota Avatar answered Oct 27 '25 00:10

palota



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!