Add local coordinator support for dev/testing#1636
Add local coordinator support for dev/testing#1636aleksandar-apostolov merged 1 commit intodevelopfrom
Conversation
Add LocalDevConfig to StreamVideoInitHelper for connecting to a local coordinator instead of the cloud. Includes HS256 JWT token generation from a secret, local token provider for refreshes, and minimal ChatClient init to prevent UI crashes. The localCoordinatorAddress parameter on StreamVideoBuilder overrides coordinator HTTP/WS URLs to use plain http/ws. Removed unused testSfuAddress/localSfuAddress since the coordinator's join response provides SFU addresses. Made-with: Cursor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
WalkthroughIntroduced local coordinator server development support by adding a Changes
Sequence Diagram(s)sequenceDiagram
participant App as Demo App
participant Helper as StreamVideoInitHelper
participant LocalConfig as LocalDevConfig
participant DataStore as User DataStore
participant ChatClient as ChatClient
participant Builder as StreamVideoBuilder
participant CoordModule as CoordinatorConnectionModule
App->>Helper: loadSdk(dataStore, localDevConfig)
alt Local Dev Config Provided
Helper->>LocalConfig: resolveToken()
LocalConfig->>LocalConfig: HMAC-SHA256 (HS256)
LocalConfig-->>Helper: token
Helper->>DataStore: Write local User
Helper->>ChatClient: Initialize with DEBUG log level
Helper->>Builder: Build with localCoordinatorAddress
Builder->>Builder: Resolve http:// & ws:// URLs
Builder->>CoordModule: Pass resolved coordinator URLs
CoordModule-->>Builder: Initialized
Builder-->>Helper: StreamVideoClient ready
else Cloud Auth Path
Helper->>Helper: Load user from cloud
Helper->>ChatClient: Initialize standard
Helper->>Builder: Build with cloud URLs
Builder-->>Helper: StreamVideoClient ready
end
Helper-->>App: SDK initialized
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt`:
- Around line 90-96: Update the initializer in StreamVideoInitHelper to validate
the local-dev configuration up front: ensure exactly one of secret or token is
provided (reject both set), and that whichever is provided is not blank (use
trim().isNotEmpty()); additionally validate coordinator, api key and user ID
fields are non-blank so empty strings fail early. Keep resolveToken() and
generateSignedToken() behavior but rely on the stronger init checks (and use
clear require(...) messages that include which field is missing/invalid).
- Around line 83-89: The auto-generated toString() of data class LocalDevConfig
exposes secret and token; override LocalDevConfig.toString() to return a safe
representation that includes coordinatorAddress, apiKey, userId but redacts or
omits secret and token (e.g., replace with "<redacted>" or show only masked
suffix), and ensure the override is declared inside the LocalDevConfig class so
any logging or serialization uses the redacted form.
In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt`:
- Around line 237-248: The resolved API/WSS URLs built in StreamVideoBuilder
(resolvedApiUrl, resolvedWssUrl) produce malformed base URLs for
Retrofit/CoordinatorConnectionModule: the local API URL lacks a trailing slash
and the cloud fallback has an extra slash ("https:///$videoDomain"). Update the
builders so the local API URL includes a trailing slash (e.g.,
"http://${it.trimEnd('/')}/"), change the cloud API fallback to
"https://$videoDomain/" (single host, trailing slash), and verify the WSS paths
remain correct for CoordinatorConnectionModule and
Retrofit.Builder().baseUrl(...) which requires a valid host and a trailing '/'.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ab0f0742-ab2a-4c79-9a3a-e1fabe56b21d
📒 Files selected for processing (3)
demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.ktstream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.ktstream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoClient.kt
💤 Files with no reviewable changes (1)
- stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoClient.kt
demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt
Show resolved
Hide resolved
demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt
Show resolved
Hide resolved
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt
Show resolved
Hide resolved
|
🚀 Available in v1.21.0 |



Goal
Adds support for connecting the demo app to a local coordinator for development and testing. This is useful for testing SFU migration, reconnection flows, and other server-side behaviors against a local environment.
Implementation
Added LocalDevConfig data class in StreamVideoInitHelper that holds local coordinator address, API key, user ID, and secret. Generates HS256-signed JWT tokens from the secret automatically.
Added localCoordinatorAddress parameter to StreamVideoBuilder that overrides the coordinator HTTP (http://) and WebSocket (ws://) URLs when set.
Removed unused testSfuAddress / localSfuAddress from StreamVideoBuilder and StreamVideoClient — SFU addresses come from the coordinator's join response, so a separate override is unnecessary.
When LocalDevConfig is passed to loadSdk(), the demo app bypasses cloud auth, uses a local token provider for refreshes, and initializes a minimal ChatClient to prevent UI crashes.
Usage
To revert to cloud, simply remove the localDevConfig parameter.
Testing
Prerequisites: Local coordinator running at :3030 with 2 SFU instances registered.
[ ] Basic connection — App connects to local coordinator, joins a call, audio/video works
[ ] Token refresh — Kill the WebSocket, verify the SDK regenerates a local JWT (not a cloud token) and reconnects
[ ] SFU migration (GoAway) — Drain/stop SFU1 while in a call; verify the client migrates to SFU2 via the coordinator
[ ] SFU migration (connection exhaustion) — Kill SFU1 process; verify after 2 failed retries the SDK auto-escalates to migrate() and gets SFU2
[ ] No regression (cloud) — Remove localDevConfig, rebuild; verify the demo app connects to the cloud coordinator as before
[ ] Graceful failure — With only 1 SFU running, trigger migration; verify the app doesn't crash (falls back to reconnect)
☑️Contributor Checklist
General
developbranchCode & documentation
stream-video-examples)☑️Reviewer Checklist
🎉 GIF
Please provide a suitable gif that describes your work on this pull request
Summary by CodeRabbit