> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Idle Timeout

> Configure CometChat Calls SDK v5 idle timeout on React Native to handle inactive participants and call session cleanup.

The idle timeout feature automatically ends a call session when a participant is alone for a specified period. This prevents abandoned calls from running indefinitely.

## Configure Idle Timeout

Set the idle timeout period when creating call settings:

```tsx theme={null}
import { CometChatCalls } from '@cometchat/calls-sdk-react-native';

const sessionSettings = {
  idleTimeoutPeriodBeforePrompt: 180000, // 180 seconds (3 minutes)
  idleTimeoutPeriodAfterPrompt: 120000,  // 120 seconds (2 minutes)
};
```

| Parameter                       | Type   | Default  | Description                                                  |
| ------------------------------- | ------ | -------- | ------------------------------------------------------------ |
| `idleTimeoutPeriodBeforePrompt` | number | `180000` | Milliseconds of inactivity before the prompt appears         |
| `idleTimeoutPeriodAfterPrompt`  | number | `120000` | Milliseconds the user has to respond before the session ends |

## How It Works

1. When all other participants leave the call, the idle timeout timer starts
2. A prompt appears 60 seconds before the timeout, allowing the user to extend the session
3. If the user doesn't respond, the session ends automatically
4. If another participant joins, the timer is cancelled

## Listen for Timeout Events

### Session Timeout Event

Listen for when the session times out:

```tsx theme={null}
CometChatCalls.addEventListener('onSessionTimedOut', () => {
  console.log('Session timed out due to inactivity');
  // Navigate away from call screen
});
```

## Disable Idle Timeout

Set a very high value to effectively disable the timeout:

```tsx theme={null}
const sessionSettings = {
  idleTimeoutPeriodBeforePrompt: 86400000, // 24 hours
};
```

## Complete Example

```tsx theme={null}
import React, { useEffect, useCallback } from 'react';
import { Alert } from 'react-native';
import { CometChatCalls } from '@cometchat/calls-sdk-react-native';

interface CallScreenProps {
  sessionId: string;
  onCallEnd: () => void;
}

function CallScreen({ sessionId, onCallEnd }: CallScreenProps) {
  const handleSessionTimeout = useCallback(() => {
    Alert.alert(
      'Session Ended',
      'The call has ended due to inactivity.',
      [
        {
          text: 'OK',
          onPress: onCallEnd,
        },
      ]
    );
  }, [onCallEnd]);

  useEffect(() => {
    const unsubscribe = CometChatCalls.addEventListener(
      'onSessionTimedOut',
      handleSessionTimeout
    );

    return () => unsubscribe();
  }, [handleSessionTimeout]);

  useEffect(() => {
    async function initializeCall() {
      try {
        const { token } = await CometChatCalls.generateToken(sessionId);

        const sessionSettings = {
          idleTimeoutPeriodBeforePrompt: 180000, // 3 minutes
          idleTimeoutPeriodAfterPrompt: 120000,  // 2 minutes
        };

        // Render call component with token and sessionSettings
      } catch (error) {
        console.error('Failed to initialize call:', error);
      }
    }

    initializeCall();
  }, [sessionId, handleSessionTimeout, onCallEnd]);

  // ... render call UI
  return null;
}

export default CallScreen;
```

## Timeout Behavior

| Scenario                  | Behavior                                |
| ------------------------- | --------------------------------------- |
| User is alone             | Timer starts counting down              |
| Another participant joins | Timer is cancelled                      |
| User extends session      | Timer resets                            |
| Timer expires             | Session ends, `onSessionTimedOut` fires |

## Related Documentation

* [Session Settings](/calls/react-native/session-settings) - Configure call settings
* [Events](/calls/react-native/events) - Handle timeout events
* [Join Session](/calls/react-native/join-session) - Start a call session
