BigPizzaV3/CodexPlusPlus · error · Error

app-server 未连接

Error message

app-server 未连接

What it means

Raised in mobile_relay_page's ensureAppServer flow: an app-server RPC was issued while appServerConnected is false or no sessionId exists, meaning the appServerConnect handshake never completed (e.g. the 30s connect timeout fired or the relay rejected the connect).

Source

Thrown at apps/codex-plus-mobile-relay/src/main.rs:885

async function ensureAppServer() {
  if (appServerConnected && appServerSessionId) return;
  appServerSessionId = appServerSessionId || `mobile-${Date.now()}-${Math.random().toString(16).slice(2)}`;
  const id = `${Date.now()}-${requestId++}`;
  const packet = await encrypt({ type: "appServerConnect", id, sessionId: appServerSessionId });
  socket.send(JSON.stringify(packet));
  await new Promise((resolve, reject) => {
    pending.set(id, { resolve, reject });
    setTimeout(() => { if (pending.delete(id)) reject(new Error("app-server 连接超时")); }, 30000);
  });
  await rpcRaw("initialize", { clientInfo: { name: "Codex++ Mobile Relay", version: "1.0.0" }, capabilities: { experimentalApi: true } });
}
async function rpc(method, params = {}) {
  await ensureAppServer();
  return await rpcRaw(method, params);
}
async function rpcRaw(method, params = {}) {
  if (!socket || socket.readyState !== WebSocket.OPEN) throw new Error("未连接");
  if (!appServerSessionId) throw new Error("app-server 未连接");
  const id = rpcId++;
  const payload = { jsonrpc: "2.0", id, method, params };
  const packet = await encrypt({ type: "appServerMessage", sessionId: appServerSessionId, message: JSON.stringify(payload) });
  const promise = new Promise((resolve, reject) => {
    pendingRpc.set(String(id), { resolve, reject });
    setTimeout(() => { if (pendingRpc.delete(String(id))) reject(new Error(`${method} 超时`)); }, method === "turn/start" ? 60000 : 30000);
  });
  socket.send(JSON.stringify(packet));
  return promise;
}
function handleAppServerMessage(text) {
  let message;
  try { message = JSON.parse(text); } catch { return; }
  if (message.id != null) {
    const resolver = pendingRpc.get(String(message.id));
    if (!resolver) return;
    pendingRpc.delete(String(message.id));
    if (message.error) resolver.reject(new Error(message.error.message || "请求失败"));

View on GitHub (pinned to f2074595a2)

Solutions

  1. Retry connect; check app-server startup logs on the relay host
  2. Fix slow app-server startup or timeout handling
  3. Verify the relay can spawn codex app-server at all
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at apps/codex-plus-mobile-relay/src/main.rs:885 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/55c8a06e69a2d064. Report an issue: GitHub.