-
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
Blazor is NOT loosing SignalR connection. Browser is! #40721
Comments
@HybridSolutions if I follow correctly, you're pointing out that the Blazor Server SignalR connection remains connected (doesn't time out/disconnect) if the dev tools (with cache disabled) is left opened. Is that correct? The fact that the tab with developer tools doesn't go to sleep isn't surprising, it's likely just an edge feature. The fact that having the dev tools open prevents the SignalR connection from going "on standby" is the part I'm unsure about. @BrennanConroy is this expected SignalR behavior? |
@TanayParikh that's exactly what I'm saying. I only tried a couple of hours max but I suppose that is enough time as a test. I can make a video of my screen if you need to see it happening. I find this behaviour amazing because all the issues out there are always mentioning a problem on SignalR connection but after all there's no issue with it since it can hold wonderfully even longer than a regular session would. You can test it for yourself too. Just go to a website like Blazorise that uses Blazor, and do my Test 1 and 2. I actually discovered this while debugging a Blazor web application. |
If the tab is "active" from the browsers point of view, then SignalR will continue to function. If the tab goes to sleep, then SignalR will stop working. This is the expected behavior. |
@BrennanConroy I'm not saying it's not the expected behavior, but the problem that troubles so many developers about Blazor apps keep disconnecting after so little time and having to deal with the browser message is not a Blazor problem after all. It's because of the browser sleeping feature. Maybe Edge could receive an indication in the header that sleeping is not allowed 😁 That would solve the problem. Have to say that Microsoft created a problem that works against Blazor with that feature... |
If you want to "solve" the sleeping tab problem there are solutions you can implement to workaround it.
Tab sleeping isn't a Microsoft only feature btw. |
Yes I know that. Just kidding. Thanks for the link. I'll give a look into it. It's important that this issue could be better documented, including perhaps warnings about this sleeping tabs Blazor "enemy", because there's a lot of complaints out there about lost connections after a very short amount of time on idle. Personally, for now, I developed a solution that automatically refreshes the current page if no connection is possible after a few attempts but I hope this is improved in Blazor in a near future. Have to ask though, shouldn't blazor deal with those sleeping tabs behind the scenes, at least as an option? They simply kill any blazor app after a few minutes. Just asking... |
@TanayParikh Thanks, I was already following those. |
Hey that's a good find, but on mobile browsers you have to assume they will always suspend the tab much more aggressively to preserve resources. So if you ask me, fix should be done on a Blazor side anyway to gracefully restore connections, or have #32113 as a workaround where we just restart the page automatically. |
Yes you are right, mobile is another nightmare. I'm using something similar to this
but with connection retry before it reloads automatically. It works great for now. |
True but if I remember correctly in .NET 5 and earlier there's like a 3s delay before your connection actually fails, not sure if they fixed that in new .NET versions. |
Using .NET 6 latest version and connection always fails to reconnect. It's a mystery why 🧐. Can't see the days of this issue to be over... |
I believe it is because after some time the state of the connection on a server side gets disposed, thus there is nothing to reconnect to, so it will always fail and there is no good way to handle that really. |
@konradbartecki I'm not sure what can be done, but something must happen because this behaviour it's not a good experience for users/clients. They just don't like that their websites and web apps keep showing these connection messages after returning from a coffee break. I'm sure .NET/Blazor team will come up with something 💪 |
We think this is covered by #32113, so will close in favour of that. |
Is there an existing issue for this?
Describe the bug
Those who work with Blazor are fully aware of the SignalR connection failed issue and the adorable "Reload" message. In a recent project, I noticed something very interesting that I never saw mentioned by anyone.
Expected Behavior
No response
Steps To Reproduce
Test 1
Test 2
Test 3
Just did the same tests but reversed the websites in tab 1 and 2. Now the website in tab 1 is working fine every time and the one in tab 2, consistently fails after awhile.
Tested this more than 5 times and the result is exactly the same every time. Opening Developer Tools with the no cache option on, is somehow preventing SignalR connection to fail or at least is allowing it to reconnect every single time without a glitch. Are you aware of this?
Exceptions (if any)
No response
.NET Version
.NET 6 latest version
Anything else?
No response
The text was updated successfully, but these errors were encountered: