-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better reconnection logic for Blazor Server #32113
Comments
I checked a debug release of my app and my assumptions were correct On mobile the browser tab is getting awaken from the sleep Solution:
WIP PR: #32122 |
@konradbartecki thanks for contacting us. We have a feature in the works to better support this scenario in 6.0. You can check it here We recommend you upvote that issue instead so that we can keep track of the interest as well as the issue covering general improvements for server-side Blazor here |
Nevermind, I see that there is a PR. We will evaluate it and see if we want to take it. |
Thanks for contacting us. We're moving this issue to the |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Found some interesting results about this issue. Please check it here |
@konradbartecki is this something we can implement as a quick fix for our Server Blazor applications until the "real" solution is possible (now pushed to V8). |
@vindberg Yes, I'm running let's say a custom fork, of dotnet/blazor with this fix only, so you could do it manually by:
See PR: #32122 |
Thanks for getting back to me. I see there are some comments from @SteveSandersonMS about the delay and checks (two times ?). Have you included those? I was hoping for an easier solution that didn't involve a custom fork of the repo. Im not sure MS knows how big an issue this is for Blazor adoption. |
Workaround: #30344 (comment) |
I'm trying this on a Blazor project with .Net 8 but the
|
It's possible this has been addressed in newer versions as I haven't focused much on reconnect logic recently, but one thing we ran into that presented challenges with reconnection was that the disposal of the scoped service provider was bound to the request lifetime, rather than the circuit lifetime, which results in |
One UX design issue to consider here (if it hasn't been already mentioned) is to have a reconnection UI that accounts for only part of the page being unresponsive. Currently we overlay the entire page, but it could be that only a single component on the page is using interactive server rendering. |
I would love to see that! |
It might be fun to start working this out as part of a debug session. It's sometimes painful when I'm trying to debug something and the browser loses the connection, which is surprising since it's a known connection and all that's happened is that I've hit a breakpoint but it takes "too long" for the connection to get refreshed, so it just hits that "1 of 8" thing. Like, how does it not know that I'm debugging? Can it figure out how it lost the connection? Or is that a stupid question? It would be useful for it "know" that I'm debugging so that it won't lose the connection. |
@rhires The problem with debugging is indeed that it might cause a timeout. I partly solved this by adding log statements on the methods. When a method is entered, left and when an exception occurs. Adding these statements manually is tedious. I use the Metalama framework to have it done automatically. Not so long ago, I wrote a few articles about logging and the use of Aspect Oriented Programming and the Metalama framewrok. You can read the articles on my website at: https://byte217.com |
# Updated Blazor Server reconnect UI Improves the default Blazor Server reconnect experience according to common customer feedback. ## Description Makes the following improvements to the Blazor Server reconnect UI: * Rather than waiting three seconds before attempting reconnection, then waiting an additional default of 20 seconds between successive attempts, the new default settings use a configurable exponential backoff strategy: * Retry as quickly as possible for the first 10 attempts * Retry every 5 seconds for the next 10 attempts * Retry every 30 seconds until reaching the user-configured max retry count * **Note**: Customers can configure their own retry interval calculation function to override the default behavior * When the user navigates back to the disconnected app from another app or browser tab, a reconnect attempt is immediately made * If the server can be reached, but reconnection fails because server disposed the circuit, a refresh occurs automatically * The default reconnect UI shows the number of seconds until the next reconnect attempt instead of the number of attempts remaining * The styling of the default reconnect UI has been modernized Fixes #55721 ## Customer Impact Customers of apps built using Blazor Server often complain about the reconnection experience, which has motivated Blazor developers to open issues like #32113 suggesting improvements to reduce the amount of time the customer spends looking at the reconnect UI. This PR addresses many of those common concerns by performing reconnection attempts more aggressively. Unless apps have overridden the default reconnection options, they will automatically get thew new reconnect behavior by upgrading to .NET 9. In addition, the default reconnect UI styling has been updated. Styling changes will not affect apps that have overridden the default reconnect UI. ## Regression? - [ ] Yes - [X] No ## Risk - [ ] High - [ ] Medium - [X] Low This change only affects the reconnection experience when using Blazor Server or Server interactivity in a Blazor Web App. We have existing automated tests verifying core reconnect functionality. It's possible that some customers may have been relying on the previous defaults, but they'll still be able to override the new defaults if desired. ## Verification - [X] Manual (required) - [X] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [X] N/A
Summary
Currently there is an issue with Blazor Server-side where it is not reconnecting circuits automatically and losing connection especially on mobile browsers.
See #23340 #26985
Motivation and goals
Reconnection attempt to the circuit was rejected by the server. This may indicate that the associated state is no longer available on the server.
In scope
onReconnectionFailed
eventonReconnectionFailed
could be used to automatically refresh the page instead of asking user to do that manually like in a screenshot shown belowDefaultReconnectionHandler.attemptPeriodicReconnection
to try to reconnect first and then delay, instead of delaying first and then trying to reconnect. (Possibly could fix Blazor Server Side. JS doesn't start after a long downtime on mobile browsers. #23340 Investigate behavior of Blazor Server on mobile when switching apps #26985)Out of scope
Risks / unknowns
Examples
DefaultReconnectionHandler.ts
Example
onReconnectionFailed
event default implementationI can take care of the implementation of this task.
Related issues
#23340
#26985
#40721
#30344
#41791
The text was updated successfully, but these errors were encountered: