Skip to main content
Quick Reference for AI Agents & Developers
// Configure idle timeout (default: 180 seconds)
val callSettings = CometChatCalls.CallSettingsBuilder(context, videoContainer)
    .setIdleTimeoutPeriod(300)  // 300 seconds = 5 minutes
    .setEventListener(object : CometChatCallsEventsListener {
        override fun onSessionTimeout() {
            // Handle auto-termination due to inactivity
        }
    })
    .build()
Available since: v4.1.0
Default timeout: 180 seconds (3 minutes alone)
Warning shown: 60 seconds before auto-termination
Available since v4.1.0

Overview

CometChat Calls SDK provides a mechanism to handle session timeouts for idle participants. By default, if a participant is alone in a call session for 180 seconds (3 minutes), the following sequence is triggered:
  1. After 120 seconds of being alone in the session, the participant sees a dialog box
  2. This dialog provides options to either:
    • Stay in the call
    • Leave immediately
  3. If no action is taken within the next 60 seconds, the call automatically ends
This feature helps manage inactive call sessions and prevents unnecessary resource usage. The idle timeout period ensures that participants don’t accidentally remain in abandoned call sessions.

Session Timeout Flow

The onSessionTimeout event is triggered when the call automatically terminates due to session timeout, as illustrated in the diagram above.

Best Practices

Choose a timeout duration that balances resource management with user experience. 180 seconds (3 minutes) is suitable for most use cases, but consider longer durations for scenarios where users may step away briefly.
Implement the onSessionTimeout() callback to clean up resources and navigate users away from the call screen. Show a clear message explaining why the call ended.
Display information about the idle timeout policy in your app’s help section or during onboarding so users understand why calls may auto-terminate.
Test the timeout flow thoroughly, including the warning dialog and auto-termination, to ensure users have enough time to respond and the experience is smooth.

Troubleshooting

Symptom: Call terminates before the expected timeout period.Cause: The setIdleTimeoutPeriod() value may be set too low, or the timeout is being triggered by other factors.Solution: Verify the timeout value in your CallSettingsBuilder. Ensure you’re setting the value in seconds (e.g., 300 for 5 minutes). Check that the call isn’t ending due to other reasons like network issues.
Symptom: Call terminates without showing the 60-second warning dialog.Cause: The default UI layout may be disabled, or the dialog is being blocked by custom UI elements.Solution: Ensure setDefaultLayoutEnable(true) is set in your call settings. Check that no custom views are overlaying the call UI and blocking the dialog.
Symptom: The onSessionTimeout() callback is not triggered when the call auto-terminates.Cause: Event listener may not be properly registered or the SDK version doesn’t support this callback.Solution: Verify you’re using SDK v4.1.0 or later. Ensure the event listener is registered using setEventListener() in your call settings before starting the session.

Next Steps