3

I have a Blazor server-side app and after a period of inactivity, the message "Attempting to reconnect to server..." appears.

I need to extend the inactivity period.

My questions:

  1. Is this maybe related to the authentication or application cookie lifetime?
  2. Is it possible to extend the timeout, and if yes, how?
  3. Is it possible to manually disconnect the circuit to test the reconnection code?
Ivan-Mark Debono
  • 15,500
  • 29
  • 132
  • 263
  • https://stackoverflow.com/questions/74638451/reconnecting-issue-in-blazor-server/74642664#74642664 Try switching off the power saving mode of browser tab. Even on desktop it causes the disconnect message to appear. – maciek Jan 25 '23 at 09:11

1 Answers1

2

That's what I gathered:

  • the browser tab goes to sleep and Blazor is unable to recover when a user comes back to a page. Switching off power-saving mode of the web browser might help.
  • the issue of Blazor reconnecting method needs improvement e.g. link link 2. There is a discussion going on GitHub and consensus is that the reconnecting mechanism needs improvement.

Right now we are waiting for a fix, which I saw vaguely scheduled for .NET 8...

The time after the message appears is the timeout for a browser to put tab to sleep. This power saving mode is switched on even on desktops. You can check the setting (and turn it off) in settings of the browser.

As for a command to keep the tab alive, I have not come across such solution. There are a lot of answers online how to reload the page once it goes into sleep, but there are no answers how to prevent it in the first place.

I have even seen a hack involving playing audio to fool heuristics of web browsers which put a Blazor tab to sleep...

maciek
  • 724
  • 2
  • 4
  • 16
  • https://stackoverflow.com/questions/74638451/reconnecting-issue-in-blazor-server/74642664#74642664 – maciek Jan 24 '23 at 21:41
  • The reconnect attempt happens on a normal desktop pc and not laptop or mobiles. Is it really related to a browser's power-mode feature? Is it possible to somehow send KeepAlive to the circuit handler? – Ivan-Mark Debono Jan 25 '23 at 04:00
  • It is really connected to browser's power-mode feature. Try disabling it in the browser settings and see what happens. Even on a desktop browsers have this setting enabled. – maciek Jan 25 '23 at 07:08