Skip to content

fix(mobile): invite join stuck on Connecting — URL scheme mismatch#2726

Open
alvinjaison wants to merge 1 commit into
block:mainfrom
alvinjaison:fix/ios-invite-connecting-stuck
Open

fix(mobile): invite join stuck on Connecting — URL scheme mismatch#2726
alvinjaison wants to merge 1 commit into
block:mainfrom
alvinjaison:fix/ios-invite-connecting-stuck

Conversation

@alvinjaison

@alvinjaison alvinjaison commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Fixes the iOS invite join flow getting permanently stuck on "Connecting…" when opening a hosted-community invite link.

Root Cause

The invite deep-link parser produces wss:// relay URLs (correct for the WebSocket scheme). These are stored directly as Community.relayUrl. However, RelayConfig.wsUrl assumed baseUrl was always HTTP-scheme:

// Before: only recognized https → wss
final scheme = uri.scheme == 'https' ? 'wss' : 'ws';

When baseUrl was wss://, this incorrectly downgraded it to ws:// (plaintext). A hosted relay at *.communities.buzz.xyz only accepts TLS connections, so the ws:// connect attempt hangs forever — no timeout on WebSocketChannel.connect.

The pairing flow works because it validates and stores URLs as https://, which the old getter handled correctly.

Fix

  1. RelayConfig.wsUrl — switch expression that passes wss/ws through unchanged and converts httpswss, httpws.
  2. RelayConfig.httpUrl (new) — inverse getter for REST endpoints. Converts wsshttps, wshttp.
  3. queryRelay + relayClientProvider — use httpUrl instead of raw baseUrl for HTTP calls (media upload, /query bridge).
  4. InviteJoinNotifier.confirmJoin — normalize URL at storage time (wsshttps, wshttp) so Community.relayUrl matches the pairing convention.

Testing

  • 13 new unit tests for RelayConfig.wsUrl/httpUrl scheme handling
  • 2 new parameterized tests for invite URL normalization
  • All 20 existing + new invite tests pass
  • flutter analyze — no issues
  • dart format — no changes needed

Closes #2662

@alvinjaison
alvinjaison requested a review from a team as a code owner July 24, 2026 16:22

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The underlying fix is needed, but this leaves existing invite-created communities only partially repaired. RelayConfig.wsUrl makes their socket connect correctly and queryRelay now converts to HTTP, but mediaUploadServiceProvider still passes config.baseUrl directly to MediaUploadService. For an already-stored wss://... community, _buildUploadRequest therefore still constructs a wss://.../upload URI for package:http, so uploads remain broken. The new normalization only applies to future invite joins; it does not rewrite the records that triggered #2662. Please either migrate/canonicalize existing stored community URLs, or consistently use config.httpUrl at every HTTP consumer (at minimum mediaUploadServiceProvider; audit the remaining config.baseUrl uses). Add coverage for an existing wss:// community exercising the HTTP endpoint derivation.

Separately, DCO is currently failing because the commit lacks the required sign-off.

@alvinjaison
alvinjaison force-pushed the fix/ios-invite-connecting-stuck branch from 972ad5c to 60326b1 Compare July 24, 2026 20:38
…e invite deep-link parser produces wss:// relay URLs, but RelayConfig.wsUrl assumed baseUrl was always HTTP-scheme (https/http). When baseUrl was wss://, the getter incorrectly downgraded it to ws://, causing the WebSocket connection to a TLS-only hosted relay to hang indefinitely with no timeout. Fix: - RelayConfig.wsUrl: handle wss/ws schemes directly (pass through) instead of only recognizing https → wss. - Add RelayConfig.httpUrl getter for REST endpoints (/query, /upload) that correctly converts wss → https, ws → http. - Update queryRelay, relayClientProvider, mediaUploadServiceProvider, and mediaGetAuthServiceProvider to use httpUrl for HTTP calls instead of raw baseUrl. - Normalize relay URL at storage time in InviteJoinNotifier.confirmJoin (wss → https, ws → http) so Community.relayUrl matches the pairing flow's HTTP-scheme convention. - Add migration in CommunityStorage.loadAll() that canonicalizes existing stored wss://ws:// community URLs to https://http:// on first load, repairing communities created before this fix. Closes block#2662 Signed-off-by: Alvin Jaison <alvinjaison@outlook.com>

Signed-off-by: Alvin Jaison <alvinjaison@outlook.com>
@alvinjaison
alvinjaison force-pushed the fix/ios-invite-connecting-stuck branch from 60326b1 to 1b4872a Compare July 24, 2026 20:52
@alvinjaison

Copy link
Copy Markdown
Author

@wesbillman Addressed your feedback in the force-push:

  • mediaUploadServiceProvider and mediaGetAuthServiceProvider now use config.httpUrl
  • Added _migrateRelaySchemes in CommunityStorage.loadAll() — rewrites existing stored wss:///ws:// to https:///http:// on first load (persisted)
  • Audited remaining config.baseUrl uses — settings_page (display label) and observer_subscription (cache key) are non-HTTP, left as-is
  • Added test coverage for the migration + HTTP derivation from a stored wss:// community
  • DCO sign-off added

48 tests pass, flutter analyze clean, dart format clean. Ready for re-review.

@alvinjaison
alvinjaison requested a review from wesbillman July 24, 2026 22:39
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.

[Bug] iOS invite join opens the community but remains stuck on “Connecting…”

2 participants