-
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
Configurable Reconnection Behavior #38305
Comments
Hello @myrup, thanks for contacting us.
In this specific case, the reconnection logic was refactored as a part of https://github.com/dotnet/aspnetcore/pull/36126/files. |
@TanayParikh What's the recommended way of making the browser reload on a reconnect then? When googling the problem the following pattern seems fairly reoccurring (now broken):
We need something like this while waiting for #27576 |
Thanks for pointing that out. I see the following resource that recommend that approach: I don't believe we have an official way to automatically reload the page on reconnect (someone can correct me if I'm wrong). If you absolutely need a workaround, you could try listening for when the As you mentioned #27576 would optimally resolve this. |
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. |
Yep you're right, I believe that'd work as well. Nice catch! |
@BrennanConroy Yeah, I also considered using that, but I gave up on it because I find the documentation lacking on how to create a Blazor stops automatically reconnecting ( |
To whom it may concern I managed to hack this together with:
But I'm still using the internal api because it's undocumented how to overload My concerns echo the unresolved #29991 , so maybe it should be reopened? |
The default wirings are here: aspnetcore/src/Components/Web.JS/src/Platform/Circuits/DefaultReconnectionHandler.ts Lines 23 to 40 in f186d9c
And it's set here: aspnetcore/src/Components/Web.JS/src/Boot.Server.ts Lines 49 to 51 in f186d9c
|
This isn't working for me, F12 error: Blazor has already started. I put the code in _layout:
Any other ideas for forcing reload after publish/app pool recycle? EDIT: Got it to work by adding autostart="false" to: <script src="_framework/blazor.server.js" autostart="false"></script>. Thanks @myrup ! |
For:
Add an autostart="false" attribute and value to the <script> tag for the Blazor script. Please see https://docs.microsoft.com/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-6.0 for more details. |
The fix with setting a custom Blazor.start().then(() => {
Object.defineProperty(Blazor.defaultReconnectionHandler, '_reconnectionDisplay', {
get() {
return this.__reconnectionDisplay;
},
set(value) {
this.__reconnectionDisplay = {
show: () => value.show(),
update: (d) => value.update(d),
rejected: (d) => document.location.reload()
}
}
});
}); |
I get an error when using any of these options: |
I'll just reiterate @BrennanConroy's point above about the official recommended approach to achieve this behavior is documented here: https://docs.microsoft.com/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-6.0#modify-the-reconnection-handler-blazor-server
|
@TanayParikh But I don't want to reconstruct the whole reconnection display! Why can't there be an official way to customise it without reconstructing it? |
@aryehsilver @TanayParikh @BrennanConroy I agree the official way is borderline useless because of its complexity to implement. I suggest making something like _reconnectionDisplay officially supported. |
@myrup That will never happen, it would be too useful! |
Re-opening to consider adding additional doc details on the reconnection behavior or provide alternate reconnection configurability. Thread summary is there are concerns with the existing documented approach as it overrides the existing reconnection behavior. |
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. |
Thanks all for the discussion, I'm closing this issue out as a duplicate, and tracking progress here: #9256 |
Describe the bug
After upgrading from asp.net core 3.1 to 6.0 Blazor is still working, but the browser can no longer locate
Blazor.defaultReconnectionHandler._reconnectCallback
.We use this to implement browser refresh on reconnections.
Exceptions (if any)
TypeError: undefined is not an object (evaluating 'Blazor.defaultReconnectionHandler._reconnectCallback)
Further technical details
dotnet --info Output
The text was updated successfully, but these errors were encountered: