跳转到内容

连接云端运行环境

Request

返回运行中云端实例的连接信息。

  • 前置条件:运行实例必须恰好处于 RUNNING 状态,且必须由你本人启动。正在停止或归档中的实例会被拒绝,即使 /cloudbrowser/page 仍显示 RUNNING。
  • 副作用:签发一个新的桌面访问令牌,并把你记录为当前连接成员。
  • 重复调用:返回的 cdpUrl 保持不变,已有的 CDP 会话继续可用;但每次调用都会签发新的桌面令牌并覆盖连接成员记录。旧的桌面 URL 不会被吊销,因此返回的每个 URL 都要当作有效凭据对待:不要记录、不要持久化。
  • 会话上限:运行实例达到最长时长后会被自动停止,归档在此之前不久开始,所以长时间运行的自动化必须能处理实例消失。
  • 用途:把 Puppeteer、Playwright 或 Selenium 连到 cdpUrl。

已记录的业务错误码:40008, 40009, 40010。 各错误码的含义见 Error Codes。任何接口还可能返回通用错误码。

Bodyapplication/jsonrequired
envIdstring(EnvironmentId)^[1-9]\d*$required

Browser profile (environment) ID. Serialized as a decimal string to avoid JavaScript precision loss on 64-bit integers.

Example:"1800000000000001"
curl -i -X POST \
  http://127.0.0.1:40000/api/cloudbrowser/connect \
  -H 'Content-Type: application/json' \
  -d '{
    "envId": "1800000000000001"
  }'

Responses

Success

Bodyapplication/json
codeintegerrequired

Return result code. 0 means success; other codes indicate exceptions.

Example:0
msgstring or nullrequired

Error message. Usually null on success.

Example:null
requestIdstring

Operation request ID. This field may be present when the request passes through the API gateway.

Example:"1d4f3ea968664593860b94b35d4ebf5e"
dataobject(CloudBrowserConnectResult)required
Response
{ "code": 0, "msg": null, "data": { "cdpUrl": "https://runtime1.morelogin.com:16167?token=c62fedaaac524e41a0f02fc4345d41cb", "accessUrl": "https://official-website.morelogin.com/browser-remote?token=eyJkZXNrdG9wVXJsIjoi...ZW52SWQiOiIyMDczMzk1NDg5NzM4OTE5OTM2In0%3D&envName=P-1267&lang=en-US" }, "requestId": "1d4f3ea968664593860b94b35d4ebf5e" }