Skip to main content
Documentation|Handle Idle Timeout in Appium

Last updated on : 09 Jan 2026

Handle Idle Timeout in Appium

This help guide explains how to configure and handle idleTimeout use cases while executing Appium tests on the Pcloudy platform.

Why Is IdleTimeout Used?

The idleTimeout feature is used to automatically terminate an Appium session if no command or request is received by the server within a specified time interval.

Key points to consider:

  • It is recommended to use explicit waits instead of hard-coded waits wherever possible.
  • Avoid using hard-coded sleep/wait statements.
  • If hard-coded waits are unavoidable, ensure the sleep duration is always less than the configured idleTimeout value.
  • If no request reaches the server within the idle timeout period, the session will be terminated automatically.

Default idleTimeout Behavior

  • By default, Pcloudy sets the idleTimeout value to 60 seconds.
  • If a testing session remains idle for more than 60 seconds, the Appium session is terminated.
  • You can override this behavior by setting the idleTimeout capability to a value between 20 and 600 seconds.

Example:

Java
capabilities.setCapability("idleTimeout", 120);
  1. Always call the driver.quit() command at the end of your test script to release the device immediately after execution.

  2. If driver.quit() is not called, the device will be released automatically based on the configured idleTimeout value.

  3. Use the appropriate driver.quit() command based on the programming language used.

driver.quit() Command by Language

LanguageCommand
Javadriver.quit();
Node.jsdriver.quit();
C#driver.Quit();
PHP$driver->quit();
Pythondriver.quit()
Rubydriver.quit
Perl$driver->quit();

When to Use the idleTimeout Capability

  • If your script uses hard-coded waits greater than 60 seconds, you must add the idleTimeout capability.
  • If hard-coded waits are less than 60 seconds, using idleTimeout is optional.
  • If your script uses explicit waits that may exceed 60 seconds, you must configure idleTimeout.

Example:

Java
capabilities.setCapability("idleTimeout", 120);

The value should always be greater than the longest wait or sleep time used in your script.

Advantages of Using idleTimeout

  • If a test execution stops unexpectedly, the device is released only after the booking duration.
  • When idleTimeout is configured, the device is released automatically after the specified idle time, ensuring better resource utilization.
  • Prevents devices from being blocked due to stalled or paused test executions.

Important Notes

  • If a hard-coded wait exceeds 10 minutes, and idleTimeout is set to the maximum value of 600 seconds, the device will still be released after 600 seconds.

  • If your hard-coded sleep time is greater than 60 seconds, you must:

    • Add the idleTimeout capability
    • Set its value greater than the sleep duration
  • The newCommandTimeout capability must always be:

    • Equal to or greater than the configured idleTimeout value

Example:

Java
capabilities.setCapability("idleTimeout", 300);
capabilities.setCapability("newCommandTimeout", 300);

Did this page help you?