-
Notifications
You must be signed in to change notification settings - Fork 56
Improve Coordinator Socket reconnection with TokenRepository #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aleksandar-apostolov
merged 54 commits into
develop
from
bugfix/rahullohra/coordinator-reconnect-jwt-token-repository
Dec 11, 2025
Merged
Improve Coordinator Socket reconnection with TokenRepository #1580
aleksandar-apostolov
merged 54 commits into
develop
from
bugfix/rahullohra/coordinator-reconnect-jwt-token-repository
Dec 11, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # stream-video-android-ui-compose/build.gradle.kts
…tion' into featture/rahullohra/video-moderation
…tion' into featture/rahullohra/video-moderation
…wt-token-repository # Conflicts: # stream-video-android-core/api/stream-video-android-core.api # stream-video-android-core/src/main/kotlin/io/getstream/android/video/generated/models/CallStatsLocation.kt
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
Contributor
SDK Size Comparison 📏
|
2. Refactor usage token
2. Refactor usage token
The log message for socket disconnection now includes the specific error for better debugging. Additionally, a TODO comment was added to the `sendData` method in `SocketActions.kt` to refactor it to return a boolean in the future.
…reconnect-jwt-token-repository # Conflicts: # stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/socket/coordinator/CoordinatorSocketConnection.kt
|
aleksandar-apostolov
approved these changes
Dec 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


Goal
Improve coordinator socket reconnection behavior after the JWT token expires.
Implementation
We need to solve 2 problems
1. Renewing the JWT token reliably
CoordinatorSocket.onVideoNetworkErrorTo fix this,
CoordinatorSocketConnectionwill now process its events on a single dedicated thread, ensuring deterministic execution and avoiding race conditions during JWT refresh.2. Single Source of Truth for JWT
To ensure that every component consistently uses the latest token:
Introduce a new
TokenRepository, responsible for storing and providing the most up-to-date JWT.Remove all logic where classes previously kept their own copy of the token string and replace it with calls to
TokenRepository.Add two new
TokenProviderimplementations:PersistingTokenProviderSimilar to
CacheableTokenProvider, but also persists the freshly fetched token intoTokenRepository.RepositoryTokenProviderA lightweight provider that simply returns the token stored in
TokenRepository.Replace
CacheableTokenProviderusage withPersistingTokenProviderwhere token updates must be tracked.Replace
ConstantTokenProviderusage withRepositoryTokenProviderwhere consumers only need to read the token.🎨 UI Changes
None
Testing
StreamService.TOKEN_EXPIRY_TIMEto trigger rapid token expiration.JWTAuth error, indicating that the JWT token has expired.