简体   繁体   English

如何处理 Blazor 的“尝试重新连接到服务器”?

[英]How to handle Blazor's "attempting to reconnect to server"?

I have a Blazor server-side app and after a period of inactivity, the message "Attempting to reconnect to server..." appears.我有一个 Blazor 服务器端应用程序,一段时间不活动后,出现消息“正在尝试重新连接到服务器...”。

I need to extend the inactivity period.我需要延长闲置期。

My questions:我的问题:

  1. Is this maybe related to the authentication or application cookie lifetime?这可能与身份验证或应用程序 cookie 生命周期有关吗?
  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?是否可以手动断开电路来测试重连代码?

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.浏览器选项卡进入休眠状态,当用户返回页面时 Blazor 无法恢复。 Switching off power-saving mode of the web browser might help.关闭 web 浏览器的省电模式可能会有所帮助。
  • the issue of Blazor reconnecting method needs improvement eg link link 2 . Blazor重新连接方法的问题需要改进,例如链接链接2 There is a discussion going on GitHub and consensus is that the reconnecting mechanism needs improvement. GitHub 进行了讨论,一致认为重连机制需要改进。

Right now we are waiting for a fix, which I saw vaguely scheduled for .NET 8...现在我们正在等待修复,我看到它模糊地安排在 .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...我什至看到了一个涉及播放音频以欺骗 web 浏览器的启发式方法的黑客攻击,该浏览器将 Blazor 选项卡置于睡眠状态......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM