mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 06:31:11 +00:00
fix(whatsapp): honor env proxy during QR login
This commit is contained in:
parent
f0b327cf68
commit
f50fb73560
7 changed files with 69 additions and 17 deletions
|
|
@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai
|
|||
### Fixes
|
||||
|
||||
- Channels/setup: treat bundled channel plugins as already bundled during `channels add` and onboarding, enabling them without writing redundant `plugins.load.paths` entries or path install records. Fixes #72740. Thanks @iCodePoet.
|
||||
- WhatsApp: honor gateway `HTTPS_PROXY` / `HTTP_PROXY` env vars for QR-login WebSocket connections, while respecting `NO_PROXY`, so proxied networks no longer fall back to direct `mmg.whatsapp.net` connections that time out with 408. Fixes #72547; supersedes #72692. Thanks @mebusw and @SymbolStar.
|
||||
- Agents/OpenAI-compatible: retry replay-safe empty `stop` turns once for `openai-completions` endpoints, so transient empty local backend responses no longer surface as “Agent couldn't generate a response” when a continuation succeeds. Fixes #72751. Thanks @moooV252.
|
||||
- Git hooks: skip ignored staged paths when formatting and restaging pre-commit files, so merge commits no longer abort when `.gitignore` newly ignores staged merged content. Fixes #72744. Thanks @100yenadmin.
|
||||
- Memory-core/dreaming: add a supported `dreaming.model` knob for Dream Diary narrative subagents, wired through phase config and the existing plugin subagent model-override trust gate. Refs #65963. Thanks @esqandil and @mjamiv.
|
||||
|
|
|
|||
|
|
@ -31,11 +31,12 @@ Healthy baseline:
|
|||
|
||||
### WhatsApp failure signatures
|
||||
|
||||
| Symptom | Fastest check | Fix |
|
||||
| ------------------------------- | --------------------------------------------------- | ------------------------------------------------------- |
|
||||
| Connected but no DM replies | `openclaw pairing list whatsapp` | Approve sender or switch DM policy/allowlist. |
|
||||
| Group messages ignored | Check `requireMention` + mention patterns in config | Mention the bot or relax mention policy for that group. |
|
||||
| Random disconnect/relogin loops | `openclaw channels status --probe` + logs | Re-login and verify credentials directory is healthy. |
|
||||
| Symptom | Fastest check | Fix |
|
||||
| ------------------------------- | --------------------------------------------------- | -------------------------------------------------------- |
|
||||
| Connected but no DM replies | `openclaw pairing list whatsapp` | Approve sender or switch DM policy/allowlist. |
|
||||
| Group messages ignored | Check `requireMention` + mention patterns in config | Mention the bot or relax mention policy for that group. |
|
||||
| QR login times out with 408 | Check gateway `HTTPS_PROXY` / `HTTP_PROXY` env | Set a reachable proxy; use `NO_PROXY` only for bypasses. |
|
||||
| Random disconnect/relogin loops | `openclaw channels status --probe` + logs | Re-login and verify credentials directory is healthy. |
|
||||
|
||||
Full troubleshooting: [WhatsApp troubleshooting](/channels/whatsapp#troubleshooting)
|
||||
|
||||
|
|
|
|||
|
|
@ -526,6 +526,13 @@ Behavior notes:
|
|||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="QR login times out behind a proxy">
|
||||
Symptom: `openclaw channels login --channel whatsapp` fails before showing a usable QR code with `status=408 Request Time-out` or a TLS socket disconnect.
|
||||
|
||||
WhatsApp Web login uses the gateway host's standard proxy environment (`HTTPS_PROXY`, `HTTP_PROXY`, lowercase variants, and `NO_PROXY`). Verify the gateway process inherits the proxy env and that `NO_PROXY` does not match `mmg.whatsapp.net`.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="No active listener when sending">
|
||||
Outbound sends fail fast when no active gateway listener exists for the target account.
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
"type": "module",
|
||||
"dependencies": {
|
||||
"@whiskeysockets/baileys": "7.0.0-rc.9",
|
||||
"https-proxy-agent": "^9.0.0",
|
||||
"jimp": "^1.6.1",
|
||||
"typebox": "1.1.33",
|
||||
"undici": "8.1.0"
|
||||
|
|
|
|||
|
|
@ -204,6 +204,33 @@ describe("web session", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("uses lowercase HTTPS proxy before uppercase for WA WebSocket connection", async () => {
|
||||
vi.stubEnv("HTTPS_PROXY", "http://upper-proxy.test:8080");
|
||||
vi.stubEnv("https_proxy", "http://lower-proxy.test:8080");
|
||||
|
||||
await createWaSocket(false, false);
|
||||
|
||||
const passed = (baileys.makeWASocket as ReturnType<typeof vi.fn>).mock.calls[0]?.[0] as {
|
||||
agent?: { proxy?: URL };
|
||||
};
|
||||
expect(passed.agent).toBeDefined();
|
||||
expect(passed.agent?.proxy?.href).toContain("lower-proxy.test");
|
||||
});
|
||||
|
||||
it("skips WA WebSocket env proxy agent when NO_PROXY covers WhatsApp Web", async () => {
|
||||
vi.stubEnv("HTTPS_PROXY", "http://proxy.test:8080");
|
||||
vi.stubEnv("NO_PROXY", "mmg.whatsapp.net");
|
||||
|
||||
await createWaSocket(false, false);
|
||||
|
||||
const passed = (baileys.makeWASocket as ReturnType<typeof vi.fn>).mock.calls[0]?.[0] as {
|
||||
agent?: unknown;
|
||||
fetchAgent?: unknown;
|
||||
};
|
||||
expect(passed.agent).toBeUndefined();
|
||||
expect(passed.fetchAgent).toBeDefined();
|
||||
});
|
||||
|
||||
it("does not create a proxy agent when no env proxy is configured", async () => {
|
||||
for (const key of [
|
||||
"ALL_PROXY",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
import { randomUUID } from "node:crypto";
|
||||
import fsSync from "node:fs";
|
||||
import type { Agent } from "node:https";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
||||
import { VERSION } from "openclaw/plugin-sdk/cli-runtime";
|
||||
import { resolveAmbientNodeProxyAgent } from "openclaw/plugin-sdk/extension-shared";
|
||||
import {
|
||||
resolveEnvHttpProxyUrl,
|
||||
shouldUseEnvHttpProxyForUrl,
|
||||
} from "openclaw/plugin-sdk/infra-runtime";
|
||||
import { danger, success } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { getChildLogger, toPinoLikeLogger } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { ensureDir, resolveUserPath } from "openclaw/plugin-sdk/text-runtime";
|
||||
|
|
@ -58,6 +62,7 @@ export {
|
|||
export type { CredsQueueWaitResult } from "./creds-persistence.js";
|
||||
|
||||
const LOGGED_OUT_STATUS = DisconnectReason?.loggedOut ?? 401;
|
||||
const WHATSAPP_WEBSOCKET_PROXY_TARGET = "https://mmg.whatsapp.net/";
|
||||
const CREDS_FLUSH_TIMEOUT_MESSAGE =
|
||||
"Queued WhatsApp creds save did not finish before auth bootstrap; skipping repair and continuing with primary creds.";
|
||||
|
||||
|
|
@ -210,17 +215,24 @@ export async function createWaSocket(
|
|||
async function resolveEnvProxyAgent(
|
||||
logger: ReturnType<typeof getChildLogger>,
|
||||
): Promise<Agent | undefined> {
|
||||
return resolveAmbientNodeProxyAgent<Agent>({
|
||||
onError: (err) => {
|
||||
logger.warn(
|
||||
{ error: String(err) },
|
||||
"Failed to initialize env proxy agent for WhatsApp WebSocket connection",
|
||||
);
|
||||
},
|
||||
onUsingProxy: () => {
|
||||
logger.info("Using ambient env proxy for WhatsApp WebSocket connection");
|
||||
},
|
||||
});
|
||||
if (!shouldUseEnvHttpProxyForUrl(WHATSAPP_WEBSOCKET_PROXY_TARGET)) {
|
||||
return undefined;
|
||||
}
|
||||
const proxyUrl = resolveEnvHttpProxyUrl("https");
|
||||
if (!proxyUrl) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
const agent = new HttpsProxyAgent(proxyUrl) as Agent;
|
||||
logger.info("Using ambient env proxy for WhatsApp WebSocket connection");
|
||||
return agent;
|
||||
} catch (error) {
|
||||
logger.warn(
|
||||
{ error: String(error) },
|
||||
"Failed to initialize env proxy agent for WhatsApp WebSocket connection",
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveEnvFetchDispatcher(
|
||||
|
|
|
|||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
|
|
@ -1446,6 +1446,9 @@ importers:
|
|||
'@whiskeysockets/baileys':
|
||||
specifier: 7.0.0-rc.9
|
||||
version: 7.0.0-rc.9(patch_hash=23ec8efe1484afa57c51b96955ba331d1467521a8e676a18c2690da7e70a6201)(audio-decode@2.2.3)(jimp@1.6.1)(sharp@0.34.5)
|
||||
https-proxy-agent:
|
||||
specifier: ^9.0.0
|
||||
version: 9.0.0
|
||||
jimp:
|
||||
specifier: ^1.6.1
|
||||
version: 1.6.1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue