Skip to content

Lost server connection is not shown with the default websocket-xhr push transport, and a silent network drop is never detected #26307

Closed

Description

@totally-not-ai

Description

With the default @Push transport (WEBSOCKET_XHR), the client does not show that the server connection is lost unless the browser fires an offline event or a UIDL request fails. If the network drops silently (packets are lost and the TCP connection is not reset, as with Wi-Fi loss on a phone or laptop), nothing detects the loss: server push updates just stop, and the UI looks connected. How fast the user sees "Connection lost" depends on how quickly the browser fires offline. That is almost immediate in Chrome on desktop and noticeably delayed or missing in Safari.

Observed behavior

Measured with Playwright (Chromium and WebKit), Vaadin 25.3.1, @Push with default settings, and a TCP proxy between browser and server:

  • Connection reset (proxy closes the sockets), no offline event: Atmosphere logs Websocket closed … wasClean: false and fires onReconnect every 5 s, but connectionState stays connected and no indicator is shown. DefaultConnectionStateHandler.pushReconnectPending only reacts when pushConnection.isBidirectional(), which is false for WEBSOCKET_XHR. That branch is meant for long polling behind a proxy, but it also catches websocket push with XHR to the server.
  • Silent drop (proxy swallows packets), no offline event, 3 minutes: connectionState never leaves connected in either browser. The websocket never closes and no heartbeat is sent (default interval 300 s). Push updates stop for good: after the network is back, the half-open websocket is never replaced, so server changes only arrive piggybacked on the next XHR response.
  • Neither the UIDL XHR nor the heartbeat XHR has a timeout. A request sent over a dead (reused keep-alive) connection can hang indefinitely, which is what Flow client never recovers if a UIDL request hangs during a network outage (Safari / WebKit) #26261 covers for the UIDL request.

Expected behavior

  • Losing the websocket of a WEBSOCKET_XHR push connection is reported like it is for WEBSOCKET: the indicator shows reconnecting, and a heartbeat verifies the connection.
  • A silent network drop is detected within a reasonable time without relying on the browser's offline event. After recovery the push connection is re-established, so server push resumes without user interaction.

Steps to reproduce

Versions

Flow main / 25.3.2. The handling of non-bidirectional push is the same as in the earlier GWT client.

Activity

  1. totally-not-ai commented on Oct 9, 2026

    @totally-not-ai
    ContributorAuthor

    Triage

    Valid bug. It has two separate parts. The first has a small, contained fix. The second needs a design decision.

    1. A lost websocket is ignored for WEBSOCKET_XHR

    AtmospherePushConnection.onReconnect() calls DefaultConnectionStateHandler.pushReconnectPending(). That method only enters RECONNECTING when pushConnection.isBidirectional() is true. For WEBSOCKET_XHR, isBidirectional() returns false because isAlwaysXhrToServer() is set. The connection then falls into the else branch, which is a no-op written for "long polling behind a proxy". The decision really depends on the transport (does Atmosphere tell us when the connection comes back?), not on the client-to-server direction.

    Proposed fix: base the check on the transport, for example pushConnection.getTransportType() === 'websocket' (or a new PushConnection method that says the transport reports reconnects). The failing test on fix/report-lost-websocket-xhr-push covers this. Points to check while doing it:

    • pushOk() ends the active request on a push reconnect. With WEBSOCKET_XHR, that request is an XHR that may still be in flight, so it must not be ended there. It should probably only happen when the transport is bidirectional.
    • PUSH has higher priority than XHR in ReconnectStateMachine. While push is the reconnect cause, a failed UIDL XHR is not retried on its own. After pushOk() the pending invocations have to be resent over XHR, as sendInvocationsToServer() already does for the bidirectional case.

    2. A silent drop (half-open TCP) is never detected

    Nothing in the stack sends a liveness probe often enough to notice this:

    Options:

    • A. Atmosphere heartbeat: enable a server-to-client heartbeat (server interceptor plus client heartbeat config). The Atmosphere client closes and reopens the socket when heartbeats stop arriving. After part 1 is fixed, that close is reported as reconnecting. This fixes push recovery with no new Flow logic, but adds periodic server traffic for every push UI, so the interval needs a config option.
    • B. Timeouts on Flow's own XHRs: add timeouts to the heartbeat and UIDL XHRs, and optionally shorten the heartbeat while push is active. This detects a dead network, but does not by itself replace a half-open websocket. A successful heartbeat after recovery would still have to force a push reconnect.
    • C. Both: A for push liveness, B (and Flow client never recovers if a UIDL request hangs during a network outage (Safari / WebKit) #26261) for hanging requests. This seems like the right end state.

    Recommendation: fix part 1 on its own first, since it is a small and testable change in DefaultConnectionStateHandler. Settle part 2 separately because it changes defaults and network traffic. A maintainer should choose between A and C.

  2. added a commit that references this issue on Oct 9, 2026
    76cb788
  3. added theissue type on Oct 12, 2026
  4. vaadin-bot commented on Nov 6, 2026

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 25.4.0-alpha5.

  5. added a commit that references this issue on Nov 8, 2026
    508ff7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions