Skip to content

fix(voip): dial relays on the web client port - #254

Open
jlucaso1 wants to merge 1 commit into
vinikjkkj:masterfrom
jlucaso1:fix/voip-relay-advertised-port
Open

fix(voip): dial relays on the web client port#254
jlucaso1 wants to merge 1 commit into
vinikjkkj:masterfrom
jlucaso1:fix/voip-relay-advertised-port

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Why

connectRelays pins every relay connection to 3478. A relay answers only on the port it advertises, and reaching one on 3478 completes the handshake and carries the uplink without ever forwarding the peer's stream back, so the call is silently one way and nothing surfaces as an error.

WhatsApp Web names the two ports itself:

var e = { CLOSE_OLD_CONNECTION_BEFORE_CALL_END: !1, FAUX_WEB_CLIENT_RELAY_PORT: 3478, TRUE_WEB_CLIENT_RELAY_PORT: 3480, USE_AUTH_TOKEN_FOR_ICE: !0 }

and builds its connection map with portOverride: (port) => shouldUseOriginalRelayPort() ? port : TRUE_WEB_CLIENT_RELAY_PORT, so by default it dials every candidate on 3480 and keeps the advertised port only as originalPort.

Overriding the advertised port is therefore right, which is why this is not a change of shape. The value was the faux one, and 3480 is already in the package as CONFIG.TRUE_WEB_CLIENT_RELAY_PORT, the fallback configureRelays applies to an endpoint that carries no port.

The gate is worth mirroring too. As it stands a relay is only ever reachable on one fixed port, however the <te2> block addresses it, and nothing outside the plugin can change that.

What

port: TRUE_WEB_CLIENT_RELAY_PORT, and the generated name follows it. The constant moves next to the behaviour it explains and is exported, so CONFIG and the media session share one definition instead of two literals.

useOriginalRelayPort, default false, dials the port each endpoint advertises instead. It threads down the same path maxConcurrentCalls already takes, and the doc comment says plainly that it is the wrong choice against WhatsApp's own relays.

plugins: [voipPlugin({ useOriginalRelayPort: true })]

Notes

The port policy could instead live in WaSctpRelay, whose configureRelays already applies relay.port || CONFIG.TRUE_WEB_CLIENT_RELAY_PORT, with the session passing ep.port through. That puts one place in charge of the dialled port. Happy to move it if you prefer that shape.

Tests

Five in packages/voip/src/call/__tests__/media-session-relays.test.ts, on what reaches configureRelays: relays are dialled on the web client port, an endpoint advertising the faux port is dialled there too, an unnamed relay is named for the address it dials, the escape hatch dials the advertised port, and two ports on one host stay two relays under it. The first three fail on master.

npm test in packages/voip passes (77 tests); tsc --noEmit, ESLint and Prettier clean.

@github-actions github-actions Bot added the fix Bug fix label Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: af3a2da4-c2d1-405b-aeb6-c36cf0901d36

📥 Commits

Reviewing files that changed from the base of the PR and between ecf0129 and 714cfdf.

📒 Files selected for processing (4)
  • .changeset/voip-relay-advertised-port.md
  • packages/voip/src/call/WaCallMediaSession.ts
  • packages/voip/src/call/__tests__/media-session-relays.test.ts
  • packages/voip/src/relay/WaSctpRelay.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/voip/src/call/WaCallMediaSession.ts

Included review availability: Your plan includes up to 2 reviews per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The VoIP relay configuration now uses the shared TRUE_WEB_CLIENT_RELAY_PORT constant set to 3480. Tests verify relay IP preservation, port replacement, and fallback names for unnamed relays.

Changes

VoIP relay port handling

Layer / File(s) Summary
Define the web-client relay port
packages/voip/src/relay/WaSctpRelay.ts
Exports TRUE_WEB_CLIENT_RELAY_PORT with value 3480 and uses it in CONFIG.
Apply the relay port to media sessions
packages/voip/src/call/WaCallMediaSession.ts, .changeset/voip-relay-advertised-port.md
WaCallMediaSession uses the shared constant for relay ports and fallback names. The changeset documents the port change.
Validate relay configuration
packages/voip/src/call/__tests__/media-session-relays.test.ts
Tests verify relay IP preservation, port replacement, and fallback names using the configured port.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🟡 Moderate · up to 714cf

The current behavior still forces relay connections to port 3478, which can make relays advertising another port unreachable and collapse distinct same-host relay endpoints. The PR is not merge-ready until advertised ports are preserved and the fallback is applied only when no port is provided.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: dialing VoIP relays on the web client port.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@jlucaso1
jlucaso1 force-pushed the fix/voip-relay-advertised-port branch from ecf0129 to 714cfdf Compare August 18, 2026 04:55
@jlucaso1 jlucaso1 changed the title fix(voip): dial each relay on the port it advertises fix(voip): dial relays on the web client port Aug 18, 2026
`connectRelays` pinned every relay connection to 3478. A relay answers
only on the port it advertises, and reaching one on 3478 completes the
handshake and carries the uplink without ever forwarding the peer's
stream back, so the call is silently one way with no error anywhere.

WhatsApp Web's own constants name 3478 `FAUX_WEB_CLIENT_RELAY_PORT` and
3480 `TRUE_WEB_CLIENT_RELAY_PORT`, and it builds its connection map with
`portOverride: (port) => shouldUseOriginalRelayPort() ? port : TRUE`, so
by default it dials every candidate on 3480 and keeps the advertised one
only as `originalPort`. Overriding the advertised port is therefore
correct; the value was not.

`useOriginalRelayPort` mirrors the other side of that gate. It defaults
to `false`, so nothing changes for a caller that does not ask, and it is
the only way to reach a relay that answers on the port it advertises,
which no amount of configuration outside the plugin could do before.
@jlucaso1
jlucaso1 force-pushed the fix/voip-relay-advertised-port branch from 714cfdf to c1d1775 Compare August 18, 2026 05:07
@vinikjkkj vinikjkkj added the needs-testing Needs to be tested by someone before merge label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix needs-testing Needs to be tested by someone before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants