bautaDocs

The CDP Gateway

bauta serve puts each persona behind a CDP endpoint of its own, so a script keeps its code and changes only how it connects.

bauta serve is the gateway: it puts each persona behind a CDP endpoint of its own. A script keeps its code and changes only how it connects.

Start the gateway

bauta setup                                # once: a free session now; offers an account (GitHub)
bauta geo update                           # the database that places a proxy's exit
bauta persona new shop --from win-intel
bauta serve

One endpoint per persona

Each persona is an endpoint on 127.0.0.1:9222:

clientendpoint
Playwright (connect_over_cdp)http://127.0.0.1:9222/persona/<name>
Puppeteer (browserWSEndpoint)ws://127.0.0.1:9222/persona/<name>
browser = playwright.chromium.connect_over_cdp("http://127.0.0.1:9222/persona/shop")
const browser = await puppeteer.connect({ browserWSEndpoint: "ws://127.0.0.1:9222/persona/shop" });

A client sees only its own persona's pages, as if the browser were its own.

Shared browsers

Personas share browsers, up to --per-browser (8) to one, among personas whose fonts, locale and screen scale match. This takes far less memory per persona. Each persona still has its own User-Agent, Client Hints, timezone, proxy and the rest of its persona, and its endpoint is the same.

To give each persona a browser of its own:

bauta serve --per-browser 1

A persona that loads unpacked extensions (extension_paths in the Python package, extensionPaths in the Node.js package) also has a browser of its own.

A shared browser that crashes takes its personas with it, and no others. Each starts again on its next connection.

Storage

A persona keeps its own profile, so cookies and storage are there on the next connection. While it is away, its profile is written out and unloaded. A persona with "ephemeral": true keeps nothing between sessions.

When a browser closes

A persona's browser closes --idle seconds after its last client, 30 by default:

bauta serve --idle 120

A window, not headless

Each browser opens a window sized to its persona's screen. On a machine without a display, install Xvfb, and bauta serve opens the windows on a virtual display of its own:

apt install xvfb

Without Xvfb it falls back to Chrome's headless mode, which a page can tell apart, and says so.

bauta serve --hidden puts the windows where no one sees them, even on a desktop:

OSwhere the windows go
Linuxa virtual display, whatever DISPLAY says
Windowsa desktop of the gateway's own, where a page is visible and focused and WebGL runs on the GPU as on any desktop
macOSChrome's headless mode

The packages' headless option, on by default, asks for it when they start the gateway.

Listen address and port

The gateway listens on 127.0.0.1, port 9222. --port changes the port. --listen 0.0.0.0 lets other machines in, and whoever reaches the port drives the personas.

The port has no password. Keep it on loopback, or put it behind your own access control.

The packages reach a gateway that runs elsewhere, such as a container's, with their gateway option or BAUTA_GATEWAY. You make its personas there.

The license

While it runs, the gateway renews the license with our server (--server, or BAUTA_SERVER) every --heartbeat seconds: 60 at least, unless the server is on this machine. It counts its active personas against the license. See sessions and the license.

Launch settings

A persona file may also set how its browser runs: its timezone and locale, its proxy, humanize, third-party cookies, ephemeral and request blocking. With a proxy, and no timezone or locale stated, they follow where the proxy exits, which the database of bauta geo update places. See launch settings and proxies.

Scripts and user activation

A script you run is the page's, not a person's. page.evaluate and the like give the page no user activation: the click or key of a person, which Chrome requires to open a popup, go fullscreen or write the clipboard. With it, a page would see an activation no input came before. Click (page.click, humanize) for what needs a person.

Looking at personas

commandwhat it does
bauta statsshows the gateway's active and queued personas, against the license
bauta inspect <name>prints a DevTools link for each page of a persona the gateway runs
bauta traffic <name>shows what the persona's pages fetched, blocked and found in the cache, by kind
bauta open <name>opens the persona's browser in a window, for a manual login

bauta stats and bauta inspect take --port when the gateway runs on another port.

Next

On this page