mirror of
https://github.com/lexmount/moli.git
synced 2026-10-08 00:01:00 +00:00
2.8 KiB
2.8 KiB
CDP server guide
moli serve exposes a CDP endpoint for remote automation clients.
Server
moli serve
moli serve --layout
moli serve --layout --resource
moli serve --host 127.0.0.1 --port 9333 --layout
Defaults:
- Host:
127.0.0.1 - Port:
9222 - Server timeout: 10 seconds
Endpoint map
| Surface | Endpoint |
|---|---|
| CDP discovery | http://127.0.0.1:9222/json/version |
| CDP targets | http://127.0.0.1:9222/json/list |
| CDP protocol | http://127.0.0.1:9222/json/protocol |
CDP discovery returns the browser WebSocket URL; prefer discovery over
hard-coding a /devtools/... path.
Client selection
- Use Playwright's
connectOverCDP/connect_over_cdpfor existing Playwright code. - Use Puppeteer's
connectwith Moli's browser WebSocket URL for existing Puppeteer code. - Use raw CDP only when the client library cannot express the required command or event.
Runtime options
- Add
--layoutfor real geometry, coordinate input, screenshots, PDFs, and screencasts. - Add individual resource flags or
--resourcewhen visual/media assets must load. - Add
--profile-dirfor persistent storage and cookies. - Add
--cookie-fileto import cookies. - Configure proxy and connection controls on
moli serve. - Add
--block-private-networksor--block-cidrsfor untrusted navigation. - Keep loopback binding unless remote clients genuinely require exposure.
Full-document screenshots
With --layout, request an automatic full-document PNG by omitting clip and
setting captureBeyondViewport:
{
"method": "Page.captureScreenshot",
"params": { "format": "png", "captureBeyondViewport": true }
}
- Automatic full-document capture requires CSS width and height to each be less than 131,072 pixels; equality is rejected.
- An explicit page-coordinate
clipbypasses that whole-document entry check, but must have positive dimensions. - Moli renders one complete bitmap. It does not stitch tiles or automatically downscale, so device-pixel, encoder, backend, and memory limits can fail earlier than the CSS boundary.
- Tile explicit clips in the client when one bitmap cannot fit. Keep each clip within the active raster and encoder limits.
Troubleshooting
- Confirm the Moli process is still running.
- Probe
/json/versionusing the exact host and port. - Ensure the client attaches or connects remotely instead of launching a bundled browser.
- Remove Chrome-only launch flags and
executablePathsettings. - Enable
--layoutwhen a failure involves real geometry or visual output. - Enable only the resource families the page requires.
- Check the installed Moli version's
serve --help. - Treat an explicit unsupported protocol error as a capability boundary; do not mask it with a synthetic success.