October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Send Messages Through Puppeteer Connection Transport

Puppeteer’s ConnectionTransport sends string messages at the connection layer. For normal CDP commands, connect to the browser and use CDPSession.send().
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ConnectionTransport.send() sends a string across Puppeteer’s low-level browser connection; it is not the usual API for issuing a Chrome DevTools Protocol (CDP) command. For a CDP command, connect Puppeteer to the browser, create a CDPSession, then call session.send(method, params). Implement a custom transport only when you need to adapt the connection itself.

Choose the right send method

Puppeteer has two distinct interfaces that can look like “sending a message”:

As an Amazon Associate I earn from qualifying purchases.

What you need to do Use Input Purpose
Send a browser-protocol command CDPSession.send() A protocol method name and its parameters Issues a CDP command and returns a promise for its result.
Provide or adapt the underlying connection ConnectionTransport.send() A string message Passes a message through a custom transport implementation supplied to puppeteer.connect().

For ordinary commands such as evaluating a script or controlling a page, use CDPSession.send(). The transport interface is a lower-level adapter boundary: Puppeteer uses it to communicate with the browser, and a custom implementation must handle that connection’s messages and closure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Send a CDP command through an existing browser connection

First obtain the browser’s WebSocket debugger endpoint. Puppeteer documents getting it from browser.wsEndpoint(); when you have access to the browser’s debugging HTTP endpoint, its /json/version response includes a webSocketDebuggerUrl. The documented endpoint format is ws://HOST:PORT/devtools/browser/<id>. See the Browser.wsEndpoint() reference.

  1. Make sure the target browser is already running with remote debugging enabled and that your process can reach its WebSocket endpoint.

  2. Connect using puppeteer.connect(), then create a page-level CDP session.

  3. Call session.send() with the protocol method and its parameters. The following Node.js example evaluates 1 + 1 and prints the returned value:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    const puppeteer = require('puppeteer');
    
    async function main() {
      const browserWSEndpoint = process.env.BROWSER_WS_ENDPOINT;
      if (!browserWSEndpoint) {
        throw new Error('Set BROWSER_WS_ENDPOINT to the browser WebSocket endpoint');
      }
    
      const browser = await puppeteer.connect({ browserWSEndpoint });
      try {
        const page = await browser.newPage();
        const session = await page.createCDPSession();
        const result = await session.send('Runtime.evaluate', {
          expression: '1 + 1',
        });
        console.log(result);
        await session.detach();
      } finally {
        await browser.disconnect();
      }
    }
    
    main().catch(error => {
      console.error(error);
      process.exitCode = 1;
    });

    Run it after setting the endpoint in your environment—for example, BROWSER_WS_ENDPOINT='ws://HOST:PORT/devtools/browser/ID' node send-cdp.js, replacing the example endpoint with the actual one. Check the exact command and parameter names against the protocol version supported by the browser you connect to; the method example does not guarantee that every browser version supports every command.

puppeteer.connect() resolves to a Browser. Its connection options are documented in the ConnectOptions reference, and the function is described in the connect() reference. The CDPSession.send() reference documents the command-level signature as send(method, params?, options?); it returns a promise for the command’s mapped result.

When and how to implement ConnectionTransport

Use a custom adapter only if Puppeteer’s normal connection mechanism does not fit your setup. The public ConnectionTransport interface defines the basic shape, not a complete transport recipe. Your implementation must expose send(message: string), receive messages through an onmessage callback, signal closure through onclose, and implement close(). Pass the instance in the transport option to puppeteer.connect().

const browser = await puppeteer.connect({ transport: customTransport });

At the interface boundary, send() takes a string message. Do not substitute a CDP method name and parameter object for that string-level contract. Puppeteer’s API reference does not provide a complete working adapter implementation or establish guarantees about reconnecting, buffering, backpressure, or error propagation. Those behaviors depend on the transport you build and should be verified against the exact Puppeteer release and underlying connection. See the ConnectionTransport interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Runtime and connection considerations

The official API pages cited here display Puppeteer version 25.12.0, checked on October 3, 2026. Confirm options against the version you install because the API can change. The ConnectOptions reference states that the protocol defaults to CDP when connecting to a browser and when launching Chrome, and to WebDriver BiDi when launching Firefox. It lists protocolTimeout with a default of 180,000 milliseconds for individual CDP calls; adjust it only if your workload needs a different limit.

The guide to running Puppeteer in a browser describes a browser-compatible puppeteer-core build connecting over WebSocket to an already running browser. In that runtime, launching or downloading a browser is unsupported because those operations rely on Node.js APIs. Use a Node.js environment when your workflow needs Puppeteer to manage browser installation or launch.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • Connection fails before a session is created: confirm the browser is running, remote debugging is available, and the endpoint is the browser WebSocket URL—not an ordinary page URL. If you use /json/version, read its webSocketDebuggerUrl value.

  • A CDP command rejects or returns an unexpected result: verify that the protocol method and parameter names match the browser’s supported protocol version, and inspect the returned error. A valid Puppeteer connection alone does not mean a particular command is supported.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A call waits too long: check whether the browser or operation is stalled. The documented default protocolTimeout is 180,000 milliseconds for individual CDP calls; a timeout is a failure signal, not evidence that the command completed.

    Best Value
    The SQL Programming Language: .
    • Used Book in Good Condition
  • A custom transport connects but commands do not flow: check that outgoing messages are delivered by send(), incoming string messages reach onmessage, and connection closure invokes onclose. The public interface does not specify buffering or reconnection behavior, so confirm those details in your own adapter and test against your installed Puppeteer version.

  • Browser-runtime code tries to launch Chromium: use an already running browser and connect over WebSocket, or move the launch workflow to Node.js. Browser-compatible Puppeteer does not support launching or downloading the browser.

Or skip the browser setup

If your goal is a website screenshot rather than a custom Puppeteer connection, ScreenshotNeo provides a screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF; its API accepts the usual screenshot parameters and supports options such as full-page capture, CSS selectors, viewport and device settings, custom CSS or JavaScript, and waits. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does ConnectionTransport.send() return a CDP command result?

No. It is the transport interface’s string-message send method. Use CDPSession.send() when you need the promise for a CDP command’s result.

Can I use Puppeteer’s browser build to launch a browser?

No. The browser-compatible build connects to an existing browser; launching or downloading one requires Node.js APIs.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.