> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Idle Timeout

> CometChat Calling SDK v5 - Idle Timeout for JavaScript

The idle timeout feature automatically ends a call session when you're the only participant remaining. This prevents sessions from running indefinitely and consuming resources.

## How It Works

1. When all other participants leave, a countdown timer starts
2. After the initial timeout period, a prompt is shown to the user
3. If the user doesn't respond, the session ends after the second timeout period

## Configure Timeout Periods

Set the timeout periods when joining a session:

```javascript theme={null}
const callSettings = {
  idleTimeoutPeriodBeforePrompt: 60000,  // 60 seconds before showing prompt
  idleTimeoutPeriodAfterPrompt: 120000,  // 120 seconds after prompt before ending
  // ... other settings
};

await CometChatCalls.joinSession(callToken, callSettings, container);
```

| Property                        | Type   | Default  | Description                                                     |
| ------------------------------- | ------ | -------- | --------------------------------------------------------------- |
| `idleTimeoutPeriodBeforePrompt` | Number | `60000`  | Time in milliseconds before showing the timeout prompt          |
| `idleTimeoutPeriodAfterPrompt`  | Number | `120000` | Time in milliseconds after the prompt before ending the session |

## Session Timeout Event

Listen for when the session times out:

```javascript theme={null}
CometChatCalls.addEventListener("onSessionTimedOut", () => {
  console.log("Session ended due to inactivity");
  // Navigate away or show a message
});
```

## Disable Idle Timeout

To effectively disable the idle timeout, set very long timeout periods:

```javascript theme={null}
const callSettings = {
  idleTimeoutPeriodBeforePrompt: 86400000,  // 24 hours
  idleTimeoutPeriodAfterPrompt: 86400000,   // 24 hours
  // ... other settings
};
```

<Note>
  The minimum value for `idleTimeoutPeriodAfterPrompt` is 60 seconds (60000 milliseconds).
</Note>
