3

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?

2
  • Why is it a problem? Can you not just let it disconnect, all the while you're fixing your code, then reconnect it later when the server will respond to SignalR pings again?
    – Caius Jard
    Aug 12, 2021 at 5:36
  • Reply to comment: NO NO NO!!! This problem is on every "BREAK" this means, exceptions, but also BREAKPOINTS. Sometimes you want to stay at a breakpoint for more than 30secs and think about it and then continue! (maybe there's nothing to fix, or you need to analyze to find out what, hence debugging with breakpoints) But continuing debugging the C# code, while the UI is already disconnected, still works, but is ofc not as useful. Jan 17 at 11:25

3 Answers 3

4

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);
    })
);
1

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>
3
  • interesting solution to configure form JS. is there any documentation on that, for all options ect. what is possible there? Jan 17 at 11:27
  • @somedotnetguy There is documentation
    – palota
    Feb 15 at 8:19
  • Blazor Server - the file you need to modify is _Host.cshtml (not _Layout.cshtml)
    – panpawel
    Jun 13 at 19:44
0

Try adding this in your Startup.cs or Program.cs, whichever one you're using and set then TimeSpan to your desired timeout length:

app.UseEndpoints(endpoints =>
    // other settings go here
    endpoints.MapBlazorHub(options => options.WebSockets.CloseTimeout = new TimeSpan(1, 1, 1));
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.