session.timeout
object to automatically manage browser session termination.
idle_timeout
parameter automatically terminates sessions after a period of inactivity. This timer starts after the last connection to the browser has disconnected, and any new connection will restart the timer. This includes live view sessions, CDP (Chrome DevTools Protocol) connections, and OS-level control connections.
The idle timeout is particularly useful for sessions with unknown length, allowing users to interact with browsers for as long as they need without keeping stale browsers alive unnecessarily. When set to 3
minutes for example, the session will terminate after 3 minutes with no active connections. The default value is 5
minutes, and you can disable automatic termination for idle sessions by setting it to -1
.
max_duration
parameter sets a hard limit on total session lifetime. Unlike the idle timeout, this will automatically terminate the session after the specified duration regardless of activity level. This acts as a safety mechanism to ensure sessions don’t run indefinitely.
The default maximum duration is 180
minutes (3 hours), but you can adjust this based on your needs. Setting max_duration
to 10
will terminate the session after exactly 10 minutes, whether the browser is actively being used or not. There is no upper limit on how long you can set the maximum duration.
"your_api_key_here"
with your actual API key. The configuration sets a 10-minute hard session limit with max_duration
, while idle_timeout
ensures the session terminates after 3 minutes of no active connections. These two timeout mechanisms work independently, so the session will end when whichever condition is met first.