dotnet / dotnet/aspnetcore

[Blazor WebApp] blazor reconnect does not work when restoring from sleep mode on PC

Open
#61,528 0 comments 5 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

.net 9.0 has improved a lot, but the reconnect logic still doesn't work when restoring from PC sleep mode. It would be great if only this part could be fixed.

When a Blazor Server app is open in a desktop browser and the PC goes to sleep, the SignalR connection terminates as expected. However, after the system wakes from sleep, the Blazor client does not properly recover the connection.

The UI is still visible, and user input (e.g., clicking buttons, filling out forms) is unresponsive to any client-side actions.
This results in a "zombie UI" where the user thinks they are still connected, but the server session is already gone.

### Expected Behavior

Upon waking from sleep mode, Blazor Server should attempt to reconnect via SignalR and either:
1. Successfully restore the session (ideal), or
2. Display the built-in "Disconnected" overlay with a reconnect button, or
3. Trigger a lifecycle event (e.g., `OnConnectionDown`) so the app can handle it manually.

### Steps To Reproduce

1. Open the Blazor Server app in Chrome or Edge on your Windows PC.
2. Your PC is set to sleep mode. Wait for about 20 minutes without doing anything. Ex) Lunch time
3. Then press the mouse or keyboard on your PC to wake it from sleep mode.
5. Interact with the page (ex. click a button that triggers a server event).
6. Verify that nothing happens. The connection is dropped, but there is no error indication in the UI.

### Exceptions (if any)

- The issue is consistent across Windows 10 and Windows 11.
- Occurs in Chrome, Edge, and Firefox (latest versions).
- Mobile devices do not exhibit this issue — they either refresh the session or trigger reconnection properly.

This is the only part of the Blazor Server experience that still breaks immersion and can lead to serious data loss or confusion for end users.

### .NET Version

9.0

### Anything else?

If the PC wakes up within a short period of time (less than a minute), the reconnect process works as expected.

However, if the PC is in sleep mode for a long period of time (e.g. lunch break), the reconnect timeout has already expired and the client becomes a zombie and no longer attempts to reconnect.

This shows that the current reconnect logic is time-based and not related to lifecycle events like sleep/resume.

It would be nice if we could reset or retry the reconnect logic when returning from sleep.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.