Skip to content

WebSocket Connection Fails to Recover After PC Sleep, Even with Manual Page Refresh #612

@ccccmagicboy

Description

@ccccmagicboy

Problem Description

When a PC resumes from sleep mode, the WebUI application's WebSocket connection fails to recover. This issue persists even after attempting a manual page refresh. The application displays a "WebUI Error: Connection with the backend is lost." message, and the browser itself shows a "Connection refused" error page when trying to reconnect. This indicates a fundamental breakdown in communication that is not resolved by standard recovery mechanisms.

This problem significantly impacts user experience, as it requires a full application restart to re-establish functionality.

Problem Reproduction Steps
Environment:

Operating System: Windows 11
Browser: Latest version of Edge
WebUI Version: Commit 20bfc37
Application: Text Editor in C using WebUI (as per issue.jpg)
Reproduction Steps:

Launch the WebUI application. Observe the initial connection status.
Put the PC into sleep mode (e.g., by closing the laptop lid or manually triggering sleep).
Resume the PC.
Observe the error message on the WebUI itself (similar to issue.jpg): The application window shows a red banner indicating "WebUI Error: Connection with the backend is lost."
Attempt to manually refresh the page (e.g., by clicking a refresh button or pressing F5).
Observe the browser's error page (similar to refresh.jpg): The browser displays a "Oops... unable to access this page" or "Connection refused" error, with suggestions like "Check your network connection" and "ERR_CONNECTION_REFUSED."
Expected Behavior:

After resuming from sleep and attempting a page refresh, the WebUI should detect the connection loss and attempt to re-establish the WebSocket connection.
Communication between the frontend and backend should resume normally.
Actual Behavior:

The WebUI displays a persistent "WebUI Error: Connection with the backend is lost." banner.
The browser shows a "Connection refused" error page, indicating that the attempt to reconnect to localhost is failing at the network level.
Even with manual page refresh, the connection is not restored.

I would appreciate it if any help:

Analyze the root cause of why the backend server becomes unreachable or fails to accept new connections after PC resume, even when the page is refreshed.
Provide guidance on how to ensure the WebSocket server and its network bindings are correctly managed across PC sleep/resume cycles.
If more diagnostic information is needed, please let me know.
Thank you for your time and effort in addressing this critical issue!

Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions