Skip to content

moq-native: enable WebSocket keep-alive on the client path#1580

Merged
kixelated merged 1 commit into
mainfrom
websocket-keepalive
Jun 1, 2026
Merged

moq-native: enable WebSocket keep-alive on the client path#1580
kixelated merged 1 commit into
mainfrom
websocket-keepalive

Conversation

@kixelated
Copy link
Copy Markdown
Collaborator

What

Wire qmux::KeepAlive::default() (5s ping / 30s deadline) into the WebSocket client connect builder in rs/moq-native/src/websocket.rs:

let session = qmux::Client::new()
    .with_protocols(alpns)
    .with_connector(connector)
    .with_keep_alive(qmux::KeepAlive::default()) // 5s ping / 30s deadline — parity with QUIC
    .connect(url.as_str())
    .await

Why

Previously the client WebSocket had no keep-alive, so a half-dead connection (network drop, NAT timeout, dead peer) would hang indefinitely — session.closed() never resolved, the reconnect loop never fired, and recovery required a process restart.

With keep-alive wired up, a half-dead WebSocket misses pings, hits the 30s deadline, the transport closes, session.closed() resolves, and the existing reconnect machinery re-establishes the session automatically. This brings the WebSocket client to parity with the QUIC path's liveness behavior.

The machinery and sensible defaults (KeepAlive::default() = 5s/30s, per qmux 0.0.7) already existed and the server accept path already used them — they just weren't wired up on the client side.

Testing

  • cargo check -p moq-native passes.

🤖 Generated with Claude Code

Wire qmux::KeepAlive::default() (5s ping / 30s deadline) into the
client connect builder, matching QUIC's liveness behavior. A half-dead
WebSocket now hits the 30s deadline, closes, and session.closed()
resolves so the existing reconnect loop re-establishes automatically —
no process restart required.

The server accept path and qmux already supported this; it just was
not wired up on the client side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kixelated kixelated enabled auto-merge (squash) June 1, 2026 19:16
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d591fd7-b2f6-47e7-8482-54d425c8e70c

📥 Commits

Reviewing files that changed from the base of the PR and between ff03db4 and 9967451.

📒 Files selected for processing (1)
  • rs/moq-native/src/websocket.rs

Walkthrough

The PR adds an explicit keep-alive configuration to the WebSocket fallback connection in qmux::Client. The change applies .with_keep_alive(qmux::KeepAlive::default()) during builder setup to align the WebSocket path's ping/deadline behavior with the QUIC connection path. No public API changes or other connection setup modifications are made.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: enabling WebSocket keep-alive on the client path in moq-native.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about what was changed, why it was needed, and how it works.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch websocket-keepalive

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kixelated kixelated merged commit 7c2e267 into main Jun 1, 2026
1 check passed
@kixelated kixelated deleted the websocket-keepalive branch June 1, 2026 19:33
@moq-bot moq-bot Bot mentioned this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant