Repository navigation
Fix: Force reconnection in case of stale connection. - #21492
Conversation
WalkthroughThe pull request introduces several modifications primarily focused on improving the connection management capabilities of the BigBlueButton HTML5 client. A new property, Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (2)
bigbluebutton-html5/imports/ui/Types/meetingClientSettings.ts (1)
102-102: LGTM. Consider adding JSDoc comment for clarity.The addition of
terminateAndRetryConnectionproperty aligns well with the PR objective of enhancing stale connection handling. The property name is clear and follows the existing naming conventions.Consider adding a JSDoc comment to provide more context about this property, such as:
/** * Time limit in milliseconds for terminating and retrying a stale connection. */ terminateAndRetryConnection: number;bigbluebutton-html5/private/config/settings.yml (1)
89-89: Minor: Remove trailing space.There's a trailing space at the end of line 89. While this doesn't affect functionality, it's good practice to remove it for consistency.
You can remove the trailing space as follows:
- # and a new connection is attempted + # and a new connection is attempted🧰 Tools
🪛 yamllint
[error] 89-89: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- bigbluebutton-html5/imports/ui/Types/meetingClientSettings.ts (1 hunks)
- bigbluebutton-html5/imports/ui/components/connection-manager/component.tsx (2 hunks)
- bigbluebutton-html5/private/config/settings.yml (1 hunks)
🧰 Additional context used
🪛 yamllint
bigbluebutton-html5/private/config/settings.yml
[error] 89-89: trailing spaces
(trailing-spaces)
🔇 Additional comments (3)
bigbluebutton-html5/private/config/settings.yml (1)
88-90: LGTM! New configuration option added for connection management.The new
terminateAndRetryConnectionsetting aligns well with the PR objectives to enhance the client's ability to handle stale connections. The 30-second timeout (30,000 ms) seems reasonable for attempting to reconnect.🧰 Tools
🪛 yamllint
[error] 89-89: trailing spaces
(trailing-spaces)
bigbluebutton-html5/imports/ui/components/connection-manager/component.tsx (2)
89-89: Specify the correct type forterminateTimeoutRefThe
setTimeoutfunction in browser environments returns anumber, so usinguseRef<number>()is appropriate. However, to ensure type safety and accommodate environments wheresetTimeoutmight return different types (likeNodeJS.Timeout), consider explicitly typingterminateTimeoutRefasReact.MutableRefObject<number | undefined>.
124-124: Handle potential undefinedterminateTimeoutRef.currentWhen calling
clearTimeout, ensure thatterminateTimeoutRef.currentis defined to avoid potential runtime issues.
| const [terminalError, setTerminalError] = React.useState<string | Error>(''); | ||
| const [MeetingSettings] = useMeetingSettings(); | ||
| const enableDevTools = MeetingSettings.public.app.enableApolloDevTools; | ||
| const terminateAndRetry = MeetingSettings.public.app.terminateAndRetryConnection; |
There was a problem hiding this comment.
Provide a default value for terminateAndRetry
If MeetingSettings.public.app.terminateAndRetryConnection is undefined, terminateAndRetry will be undefined, which may cause issues with setTimeout. To ensure reliable behavior, provide a default value.
Apply this diff to set a default value:
-const terminateAndRetry = MeetingSettings.public.app.terminateAndRetryConnection;
+const terminateAndRetry = MeetingSettings.public.app.terminateAndRetryConnection ?? 30_000; // Default to 30 seconds📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const terminateAndRetry = MeetingSettings.public.app.terminateAndRetryConnection; | |
| const terminateAndRetry = MeetingSettings.public.app.terminateAndRetryConnection ?? 30_000; // Default to 30 seconds |
| terminateTimeoutRef.current = window.setTimeout(() => { | ||
| // The apollo client will try to reconnect after the connection is terminated | ||
| // if the option to reconnect is true | ||
| apolloContextHolder.getLink().terminate(); | ||
| }, terminateAndRetry); |
There was a problem hiding this comment.
Ensure terminateTimeoutRef is cleared on component unmount
To prevent potential memory leaks, ensure that terminateTimeoutRef.current is cleared when the component unmounts.
Apply this diff to add cleanup:
useEffect(() => {
const interval = setInterval(() => {
// existing code
}, 5_000);
return () => {
clearInterval(interval);
+ if (terminateTimeoutRef.current !== undefined) {
+ clearTimeout(terminateTimeoutRef.current);
+ }
};
}, []);Committable suggestion was skipped due to low confidence.
Prevent multiple timeouts from being scheduled
When the condition remains true over multiple intervals, multiple timeouts could be scheduled without clearing the previous ones. This can lead to unexpected behavior. Check if a timeout is already set before scheduling a new one.
Apply this diff to prevent redundant timeouts:
if ((tsNow - tsLastMessageRef.current > boundary.current) && connectionStatus.getServerIsResponding()) {
+ if (!terminateTimeoutRef.current) {
connectionStatus.setServerIsResponding(false);
terminateTimeoutRef.current = window.setTimeout(() => {
// The apollo client will try to reconnect after the connection is terminated
// if the option to reconnect is true
apolloContextHolder.getLink().terminate();
+ terminateTimeoutRef.current = undefined;
}, terminateAndRetry);
+ }
} else if ((tsNow - tsLastPingMessageRef.current > boundary.current) && connectionStatus.getPingIsComing()) {Committable suggestion was skipped due to low confidence.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
bigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.ts (1)
6-6: LGTM! Consider adding a comment for clarity.The addition of
terminateAndRetryConnectionaligns well with the PR objectives for improving connection management. The 30-second timeout seems reasonable for terminating and retrying connections.Consider adding a brief comment to explain the purpose and unit of measurement for this setting:
+ // Timeout in milliseconds for terminating and retrying stale connections terminateAndRetryConnection: 30000,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- bigbluebutton-html5/imports/ui/components/connection-manager/component.tsx (2 hunks)
- bigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- bigbluebutton-html5/imports/ui/components/connection-manager/component.tsx
🧰 Additional context used
Automated tests Summary✅ All the CI tests have passed! |
|
30 seconds seems to align with the SFU re-connection! 👍️ |
The watchdog added in #21492 arms a timer to terminate and reconnect the GraphQL websocket when no message arrives for 15 s. It only arms the timer when the ref is empty, but the ref was never cleared: not when messages resume, nor when the timer fires. So the forced reconnect worked once per page load. Every later stale period left the client silent until the user reloaded. Clear the ref in both places so every stale period gets its own timer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The watchdog added in #21492 arms a timer to terminate and reconnect the GraphQL websocket when no message arrives for 15 s. It only arms the timer when the ref is empty, but the ref was never cleared: not when messages resume, nor when the timer fires. So the forced reconnect worked once per page load. Every later stale period left the client silent until the user reloaded. Clear the ref in both places so every stale period gets its own timer. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 979a522)



What does this PR do?
This PR intends to make the client terminates the connection when notice that it's stale, the own apollo client tries to reconnect when the
shouldRetryreturnstrue, I also set a configurable amount of time to try the reconnection.Closes Issue(s)
Closes #21062
How to test
Join the client and switch network or turn on/off a VPN.