Session Management
Closing a session
Section titled “Closing a session”client.close()Closes the browser from the most recent connect_url() call. If no session is active, this is a no-op.
await client.close();// Or close a specific session:await client.close('session-id-here');Reconnecting to a session
Section titled “Reconnecting to a session”If your client disconnects, you can reconnect to the same browser without creating a new one:
session_id = client.last_session_id
# Later, reconnect:ws_url = client.reconnect_url(session_id)browser = p.chromium.connect_over_cdp(ws_url)const sessionId = client.sessionId;
// Later, reconnect:const wsUrl = await client.reconnectUrl(sessionId);const browser = await chromium.connectOverCDP(wsUrl);Checking session count (Node.js)
Section titled “Checking session count (Node.js)”const { limit, remaining } = await client.getSessionCount();console.log(`${remaining}/${limit} sessions available`);Session properties
Section titled “Session properties”After calling connect_url() / connectUrl():
| Property | Python | Node.js | Description |
|---|---|---|---|
| Session ID | client.last_session_id | client.sessionId | Unique session identifier |
| VNC URL | client.last_vnc_url | client.vncUrl | noVNC URL (when vnc=True) |