Skip to content

Backport OpenNOW-Switch #49 signaling and allocation hardening - #30

Open
ducktailgoat wants to merge 2 commits into
OpenCloudGaming:mainfrom
ducktailgoat:fix/switch-49-signaling-recovery
Open

ducktailgoat wants to merge 2 commits into
OpenCloudGaming:mainfrom
ducktailgoat:fix/switch-49-signaling-recovery

Conversation

@ducktailgoat

@ducktailgoat ducktailgoat commented Nov 8, 2026 •

Copy link
Copy Markdown

Stacked on #28 (its first commit is the first one here); review the last commit only.

Summary

Backports the parts of OpenCloudGaming/OpenNOW-Switch#49 that PS5 did not already have, limited to changes that only affect responses PS5 fails on today. Most of the Switch PR's WebSocket work (binary and fragmented frames, close codes, rejected-upgrade status, query escaping, offer timeout) was already present.

Signaling, in Stream::tick:

 ws_->poll()
 if socket lost
-  fail("Signaling: ...")                 # ends a running stream
+  if answer not sent yet
+    fail("Signaling: ...")               # unchanged
+  else
+    note "SIGNALING lost after answer: ..." in media.log
+    drop the socket, keep PeerConnection and media
+    (WebRTC state and video watchdogs still end a stream whose media stops)

CloudMatch allocation, in cloud.cpp:

 connection parsing
+  usage / port accepted as numeric strings
+  appLevelProtocol 4: signaling uses the entry's port instead of 443
+  bare IPv6 hosts bracketed in derived wss:// URLs
+  explicit https:// signalingUrl rewritten to wss://
+  wss:// URLs rejected with userinfo, fragments or bad ports
+  placeholder hosts skipped: ".cloudmatchbeta.nvidiagrid.net", 0.0.0.0, ::
 polling
+  12 ready polls without a usable address -> fail, session retained
+  APP_PATCHING_STATUS poll without a session object -> keep waiting

Not ported, to keep the working launch path unchanged: preferring WebRTC over RTSP connection entries, never using RTSP ports as media hints, dropping the serverIp / sessionControlInfo signaling fallbacks (current PS5 tests assert these), retrying signaling before the first offer, and queue-ad reporting.

Evidence

  • Signaling (tests/stream_lifecycle_test.cpp): start, receive offer, answer sent, then drop the socket.
    Before: stream.failed() and the stream is released.
    After: stream stays active, the socket is freed (sockets==0, peers==1), the loss is logged, later heartbeat ticks do nothing. Pre-answer socket loss still fails as before.
  • Allocation (tests/cloud_test.cpp): six new NetworkCase fixtures (string numbers, protocol-4 port, IPv6, https signalingUrl, placeholder hosts, malformed explicit URL), a 12-poll bounded ready wait, and a patching poll without session.
    Before: the first new fixture never becomes ready ("usage":"14").
    After: all pass, together with the existing fixtures.
  • Full tools/test-port.sh gives identical results on this branch and on its base.
  • Console (PS5, build of this branch plus Let FTP read diagnostics logs in the storage root #29 and the region fix): two launches with session recovery. OFFER / ANSWER, 2560x1440 for 60 to 68 s, 7824 frames decoded, 0 decode errors. Signaling was never lost during these runs, so the post-answer loss path is still covered only by the host test.

Merge Danger

Door: two-way. No persisted data or format changes.

Blast Radius: stream lifetime and session allocation.

A stream now survives signaling loss after the answer. If NVIDIA uses a post-answer close to end sessions, the stream would end through the media watchdogs instead of immediately: on WebRTC failure, or about 12 s after video stops decoding (keyframe request at 8 s, failure 4 s later). Stricter URL and host validation could reject an address the old code accepted; the existing fixtures, including the shape of the console-verified launch (route=stream), still pass.

Since 2026-10-27 CloudMatch picks the streamer from the client identity.
NATIVE / NVIDIA-CLASSIC sessions only get classic RTSP endpoints, so the
WebRTC signaling socket connects but no SDP offer ever arrives and the
stream stays on "Connecting stream".

CloudMatch /v2/ requests (session create, poll, stop, server info and
network test) now send BROWSER / WEBRTC, client version 2.0.89.154,
nv-browser-type CHROME and a plain Chrome user agent, without the GFN-PC
x-nv-client-identity. Session and network test bodies use
clientPlatformName "browser". Catalog requests keep the native identity.
Ported from OpenNOW-Switch #48 (issue #47).
Ports the parts of OpenNOW-Switch #49 that PS5 did not already have,
limited to changes that only affect responses PS5 fails on today, so the
console-verified launch path is unchanged.

Signaling:
- Losing the signaling socket after the answer no longer ends a running
  stream. The socket is closed and dropped, the loss is logged to
  media.log, and the existing WebRTC state and video watchdogs still end
  a stream whose media stops. Losses before the answer still fail.

CloudMatch allocation:
- Accept usage and port values sent as strings.
- Use the connection port for appLevelProtocol 4 signaling entries.
- Bracket bare IPv6 hosts in derived signaling URLs.
- Rewrite an explicit https:// signalingUrl to wss:// and validate
  explicit and resourcePath URLs (no userinfo, fragments or bad ports).
- Skip placeholder hosts such as ".cloudmatchbeta.nvidiagrid.net",
  0.0.0.0 and :: instead of dialing them.
- Fail with the session retained after 12 ready polls without a usable
  streaming address instead of polling forever.
- Keep waiting when an APP_PATCHING_STATUS poll omits the session.

Not ported: queue-ad reporting, retrying signaling before the first
offer, and the connection preference changes (preferring WebRTC over
RTSP entries, never using RTSP ports as media hints, dropping the
serverIp/sessionControlInfo signaling fallbacks), which change endpoint
selection for responses that work today.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4b3cdd0-d986-4639-89f4-378f2ea75bb1
Commits

Reviewing files that changed from the base of the PR and between b980681 and 711c5cd.

Files selected for processing: 7

  • src/cloud.cpp
  • src/cloud.hpp
  • src/http.cpp
  • src/stream/stream.cpp
  • tests/cloud_test.cpp
  • tests/http_test.cpp
  • tests/stream_lifecycle_test.cpp
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

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