Skip to content

fix: concurrent WebVNC viewers can fail to connect - #133226

Merged
steipete merged 1 commit into
mainfrom
codex/cloud-vnc-single-connection
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cloud-vnc-single-connection

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users opening several WebVNC viewers for a cloud session or paired node could receive a stream error even below the Gateway observer limit. The native TigerVNC server could blacklist the node's loopback address while other viewers remained connected.

Why This Change Was Made

Each viewer previously opened a disposable RFB security probe and then a second TCP connection for authentication. TigerVNC counts accepted attempts before authentication, so concurrent viewers doubled the pending attempts and could exhaust its existing protection threshold.

The node now inspects and retains one TCP connection per viewer. A bounded handshake adapter replays the inspected banner and security offer to the existing Gateway preauthentication flow and consumes only its identical version reply. Both owners share one version parser. Authentication, TLS pinning, ticket and placement checks, observer limits, and server blacklist protection remain unchanged.

The retained stream also owns cancellation and failed startup cleanup. Normal EOF drains buffered bytes, and the shared desktop/portal transport waits for the WebSocket close acknowledgement before completing its control-channel invocation, so the Gateway can receive the last frame before retiring the stream. Abort still closes immediately.

User Impact

Concurrent cloud and paired-node viewers no longer create extra unauthenticated probe connections. Desktop and portal streams preserve their final response on normal peer closure.

Named follow-up: Gateway-host status/readiness uses a separate standalone-probe contract. Repeated status checks without authentication can still accumulate TigerVNC attempt marks; this PR does not change that contract or remove the server's legitimate limit on simultaneous pending authentications.

Evidence

The original three-viewer reproduction, using real TCP/WebSocket transports and TigerVNC 1.15.0's accept/authentication counter semantics, produced five accepted connections, one blocked connection, and two authenticated viewers. The same scenario on the fix produces exactly three accepted connections, no blocked connections, and three authenticated viewers. The new paired-node and cloud-worker integration regressions also fail against the original command because it opens six connections for three viewers.

All 83 focused tests pass across the RFB probe/preauthentication, node desktop command, shared stream transport, portal command, and paired/cloud observe integration suites. Coverage includes RFB 3.3/3.7/3.8 and macOS 3.889, split/coalesced handshakes, changed-version refusal, cancellation, failed credentials/startup, a paused consumer retaining a final 32 KiB response, view-only filtering, three concurrent viewers, final-frame delivery before command completion, direct/proxied TLS portal and desktop EOF, successful finalization after paused EOF, and close acknowledgement when target write backpressure ends without a drain event. A real queued-write test holds an 8 MiB TCP write pending with a second wrapper write, sends FIN with a final response, and verifies both callbacks, every outgoing byte, the final response, and full stream completion; cancellation and pre-attach FIN variants also pass.

Independent P0–P2 reviews found shutdown edges around duplicate finalization, paused acknowledgement reads, native EOF leaving outer writable admission open, and competing native/wrapper finalizers with queued writes. Each was reproduced with a failing regression before repairing the stream lifecycle; the final complete-source P0–P2 review has no actionable findings.

Production LOC is +246/-114 (net +132); tests are +667/-201. The growth is the explicit owner for one retained socket and its buffered EOF lifecycle. It replaces the second connection, duplicate version parser, and separate flowing read buffer; there is no new configuration, dependency, retry, timeout increase, or compatibility path.

All selected repository guards passed in composed verification. The canonical core-test typecheck was rerun successfully in a fresh frozen install because its transitively imported UI Vite config could not resolve pako declarations in the shared local dependency layout. Source hashes and modes were verified unchanged after tests, and no dependency files changed.

Exact-head CI passed on the first attempt. The exact committed package also passed 8/8 compiled stress subprocesses covering 32 observer/auxiliary WebSocket and 36 worker authority/shutdown scenarios in 133.993 seconds, with no retries, failures, or stderr. This is supporting proof of the surrounding compiled owners; it does not exercise the outbound node TCP splice.

The exact committed package was exercised through the real cloud-session UI on Linux with TigerVNC 1.15.0, TLS pins, and CUA doctor checks passing. TigerVNC retained its default blacklist protection (enabled, threshold 5, timeout 10 seconds), with no overrides. The initial local disk guard rejected startup before any session or lease allocation; disposable test fixture/state was moved to a filesystem with sufficient headroom before retry. No package source or storage safety guard changed.

Native before/after trace, with addresses and session identifiers omitted:

Scenario Original implementation Exact commit 7f1d2be9fde4
UI plus three existing viewers, then three additional concurrent viewers Two added viewers ready; one closed before the RFB version. The server journal recorded three disposable probe disconnects and a blacklist rejection. All three added viewers ready on the first attempt; all six helper viewers received frames.
Server connections for the three added viewers Disposable probe and authentication used separate connections. Exactly three accepted TCP connections; zero blacklist or authentication errors.
Native CUA interaction observed by WebVNC Not claimed as part of this failing burst. The click changed the visible counter from 0 to 3; a fresh observation showed 3. Both actions completed with strict verification and native close acknowledgement.

All six original helper connections remained intact for 341.1 seconds without reconnecting, and the real WebVNC view still showed the counter at 3. Canonical idle reclaim then completed in 59.258 seconds: all six original connections closed with owner code 1012 after the reclaim RPC, all seven helper processes exited successfully, the placement was reclaimed, the environment was destroyed, and the provider independently reported the lease released. The actual UI disconnected. A fresh RFB frame immediately before reclaim also showed 3.

The passive helpers establish initial pixels and connection continuity; current pixels were separately checked in the actual UI. Read-only verifier precondition mistakes were corrected and preserved in the evidence, but no native viewer or CUA action was retried. This is exact PR-head package proof, not proof of every later main change or active Stop terminal persistence; combined-current-main Stop validation is a separate follow-up.

Review Follow-through

The latest ClawSweeper review found no actionable code or security findings. Its rank-up requests are addressed by the native before/after trace above and a direct current-main comparison: main e42bb23a84933669c67173ed3b7640567b6f1ce9 has no changes since the reviewed base in the affected desktop owner subtree, desktop/portal commands, shared node transport, or cloud-worker documentation; a merge simulation is clean. The PR head and exact-head CI remain unchanged.

The automated stored-data warning on rfb-preauth.ts is not applicable: the diff replaces an in-memory RFB version parser with the canonical parser and validates the negotiated wire version. It adds no serialized persistent state, schema, database, configuration, or migration contract.

Retain each node viewer's inspected RFB connection through authentication
so concurrent cloud and paired-node viewers do not double TigerVNC's
pending connection attempts. Preserve buffered final frames and finish
WebSocket closure before retiring desktop or portal control invocations.
@steipete
steipete requested a review from a team as a code owner August 30, 2026 09:26
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 5:47 AM ET / 09:47 UTC.

ClawSweeper review

What this changes

The branch retains each node viewer’s inspected loopback RFB connection through Gateway authentication and waits for WebSocket closure after normal desktop or portal EOF.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for maintainer review. The patch removes the source-proven second RFB connection per viewer and has focused integration coverage, but the supplied PR body still identifies native TigerVNC concurrency validation as outstanding; current-main comparison was also unavailable in this partial checkout.

Priority: P1
Reviewed head: 7f1d2be9fde4d56a316307e017ea449fb4ac83d3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has strong source-level and integration coverage, but the stated native TigerVNC scenario is not yet inspectable.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply because Repository State identifies the author as a MEMBER. The available PR body nevertheless says native TigerVNC three-viewer validation remains outstanding; the synthetic socket and WebSocket tests are supplemental evidence only.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply because Repository State identifies the author as a MEMBER. The available PR body nevertheless says native TigerVNC three-viewer validation remains outstanding; the synthetic socket and WebSocket tests are supplemental evidence only.
Evidence reviewed 6 items Retained connection owner: The new connector reads the banner and security offer, wraps the existing socket, replays the inspected bytes, and returns that stream rather than a port for a second dial.
Desktop caller consumes retained stream: The node desktop command now passes the connected RFB stream into the shared transport after its security classification, preserving loopback-only validation and ticketed Gateway attachment.
Pre-patch source mechanism: The merge-base implementation first probed RFB, then passed a port to the transport, whose default path created another loopback socket; this establishes the source reproduction for doubled connections.
Findings None None.
Security None None.

How this fits together

WebVNC viewers attach through the Gateway to an enrolled node, which relays a loopback RFB desktop connection over a ticket-authenticated WebSocket. The changed node-side owner now preserves the initial RFB handshake connection and controls its end-of-stream behavior.

flowchart LR
A[WebVNC viewer] --> B[Gateway observer]
B --> C[Ticketed node command]
C --> D[Loopback RFB handshake]
D --> E[Retained RFB stream]
E --> F[Gateway byte relay]
F --> A
Loading

Decision needed

Question Recommendation
Should this maintainer-owned PR wait for the exact-head native TigerVNC three-viewer validation that its body identifies as required before merge? Record native validation: Run the three-viewer TigerVNC scenario on the exact head and attach a redacted before/after connection trace.

Why: Synthetic transport tests establish the code path, but they cannot establish the server-specific acceptance-counter behavior described by the PR.

Before merge

  • Resolve merge risk (P1) - Native TigerVNC three-viewer behavior remains unverified in the supplied evidence; the PR body explicitly says this validation is required before merge.
  • Resolve merge risk (P1) - This availability-sensitive lifecycle change could still differ on the current main, which the partial checkout could not materialize for comparison.
  • Complete next step (P2) - No code defect was found in the reviewed patch; merge readiness depends on native-server proof and a fresh-main comparison, not an automated repair.
Agent review details

Security

None.

PR surface

Source +132, Tests +466, Docs 0. Total +598 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 246 114 +132
Tests 5 667 201 +466
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 914 316 +598

Review metrics

Metric Value Why it matters
Production versus test LOC production +246/-114 (net +132); tests +667/-201 (net +466) The production growth implements retained-socket and EOF ownership; no net-neutral equivalent was evident from the inspected pre-patch split between probing and transport.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/desktop/rfb-preauth.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add native TigerVNC proof (recommended)
    Before merge, attach exact-head evidence that three simultaneous viewers create three accepted connections and all authenticate successfully.
  2. Pause pending native capacity
    Hold the PR until a host meeting the native validation safety floor is available.

Technical review

Best possible solution:

Keep the single-connection owner design, attach a redacted exact-head TigerVNC concurrency trace, then refresh the review against current main before merge.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: the merge-base first opened a disposable RFB probe and then the stream transport opened another socket, so three simultaneous viewers create six accepted connections. Native TigerVNC execution was not available in this review environment.

Is this the best way to solve the issue?

Yes, provisionally: retaining the socket at the RFB inspection owner removes the duplicate dial without changing Gateway ticket or loopback checks. Native-server evidence and a current-main refresh are still needed before a merge decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8cf4351e8fc1.

Labels

Label justifications:

  • P1: The change addresses concurrent desktop-viewer failures on a working cloud or paired-node workflow.
  • merge-risk: 🚨 availability: Retained socket ownership and EOF settlement can affect whether desktop and portal streams connect or complete.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply because Repository State identifies the author as a MEMBER. The available PR body nevertheless says native TigerVNC three-viewer validation remains outstanding; the synthetic socket and WebSocket tests are supplemental evidence only.

Evidence

What I checked:

  • Retained connection owner: The new connector reads the banner and security offer, wraps the existing socket, replays the inspected bytes, and returns that stream rather than a port for a second dial. (src/gateway/desktop/rfb-probe.ts:209, 7f1d2be9fde4)
  • Desktop caller consumes retained stream: The node desktop command now passes the connected RFB stream into the shared transport after its security classification, preserving loopback-only validation and ticketed Gateway attachment. (src/node-host/desktop-stream-command.ts:116, 7f1d2be9fde4)
  • Pre-patch source mechanism: The merge-base implementation first probed RFB, then passed a port to the transport, whose default path created another loopback socket; this establishes the source reproduction for doubled connections. (src/node-host/node-stream-transport.ts:162, 357078cf7087)
  • Boundary regression coverage: Focused tests cover one retained connection across RFB versions, cancellation, queued writes, terminal bytes, and three concurrent paired-node and worker observers. (src/gateway/desktop/rfb-probe.test.ts:165, 7f1d2be9fde4)
  • PR-head provenance: The reviewed head has the verified merge-base as its recorded parent, and the exact introduced diff contains the retained-socket and EOF lifecycle changes. (src/gateway/desktop/rfb-probe.ts:137, 7f1d2be9fde4)
  • Current-main limitation: The supplied fetched-main object could not be materialized because the checkout’s promisor remote could not resolve, so supersession against current main remains unverified.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted exact-head TigerVNC three-viewer before/after trace.
  • Refresh the review once current main can be materialized.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-30T09:37:21.992Z sha 7f1d2be :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 6549b0a into main Aug 30, 2026
264 checks passed
@steipete
steipete deleted the codex/cloud-vnc-single-connection branch August 30, 2026 10:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…#133226)

Retain each node viewer's inspected RFB connection through authentication
so concurrent cloud and paired-node viewers do not double TigerVNC's
pending connection attempts. Preserve buffered final frames and finish
WebSocket closure before retiring desktop or portal control invocations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant