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 serveOne endpoint per persona
Each persona is an endpoint on 127.0.0.1:9222:
| client | endpoint |
|---|---|
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 1A 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 120A 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 xvfbWithout 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:
| OS | where the windows go |
|---|---|
| Linux | a virtual display, whatever DISPLAY says |
| Windows | a desktop of the gateway's own, where a page is visible and focused and WebGL runs on the GPU as on any desktop |
| macOS | Chrome'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
| command | what it does |
|---|---|
bauta stats | shows 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
- Sessions and the license: how many personas can be active, and what happens over the cap.
bauta serve: every flag and its default.- Playwright and Puppeteer: connecting your scripts.