openclaw - ✅(Solved) Fix [Bug]: WhatsApp extension's QR code Connection ignore HTTP/SOCKS5 Proxy as env variable [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72547Fetched 2026-04-28 06:34:39
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2closed ×1commented ×1

the issue is same to #2153 , but the code affected is no located in ~/.nvm/versions/node/v22.16.0/lib/node_modules/openclaw/dist/extensions/whatsapp/connection-controller-Cxgtxfr6.js It affects the QR code linking of channel whatsapp, specially user was using http proxy to get through China's network firewall

  • openclaw version: 2026.4.24
  • MacOS 26.3.1

the code works after modified as below:

	const { version } = await fetchLatestBaileysVersion();
        // the original code ignore the http proxy in terminal
	const agent1 = await resolveEnvProxyAgent(sessionLogger);
	const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent1);
	

	// so force it to read env variable of http proxy, before makeWASocket call
	const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
	const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;

	const sock = makeWASocket({
		auth: {
			creds: state.creds,
			keys: makeCacheableSignalKeyStore(state.keys, logger)
		},
		version,
		logger,
		printQRInTerminal: false,
		browser: [
			"openclaw",
			"cli",
			VERSION
		],
		syncFullHistory: false,
		markOnlineOnConnect: false,
		agent,
		fetchAgent
	});

Error Message

Waiting for WhatsApp connection... WhatsApp Web connection ended before fully opening. status=408 Request Time-out WebSocket Error (Client network socket disconnected before secure TLS connection was established) WhatsApp login failed: Error: status=408 Request Time-out WebSocket Error (Client network socket disconnected before secure TLS connection was established)

Root Cause

the issue is same to #2153 , but the code affected is no located in ~/.nvm/versions/node/v22.16.0/lib/node_modules/openclaw/dist/extensions/whatsapp/connection-controller-Cxgtxfr6.js It affects the QR code linking of channel whatsapp, specially user was using http proxy to get through China's network firewall

  • openclaw version: 2026.4.24
  • MacOS 26.3.1

the code works after modified as below:

	const { version } = await fetchLatestBaileysVersion();
        // the original code ignore the http proxy in terminal
	const agent1 = await resolveEnvProxyAgent(sessionLogger);
	const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent1);
	

	// so force it to read env variable of http proxy, before makeWASocket call
	const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
	const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;

	const sock = makeWASocket({
		auth: {
			creds: state.creds,
			keys: makeCacheableSignalKeyStore(state.keys, logger)
		},
		version,
		logger,
		printQRInTerminal: false,
		browser: [
			"openclaw",
			"cli",
			VERSION
		],
		syncFullHistory: false,
		markOnlineOnConnect: false,
		agent,
		fetchAgent
	});

Fix Action

Fix / Workaround

	const { version } = await fetchLatestBaileysVersion();
        // the original code ignore the http proxy in terminal
	const agent1 = await resolveEnvProxyAgent(sessionLogger);
	const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent1);

PR fix notes

PR #72692: fix(whatsapp): wire env HTTP proxy through HttpsProxyAgent directly

Description (problem / solution / changelog)

Summary

Fixes #72547 — WhatsApp QR-code linking silently bypasses HTTP/HTTPS proxy env vars in bundled installs, causing pairing to fail with status=408 Request Time-out behind regional firewalls (e.g. macOS from inside China).

Also fixes #70149 — same root cause. The reporter independently traced the failure to resolveAmbientNodeProxyAgent() falling back to no agent (because the bundled whatsapp extension has no proxy-agent dep), and confirmed that an explicit HttpsProxyAgent works end-to-end against the same proxy and target — which is exactly the path this PR adopts.

Root cause

extensions/whatsapp/src/session.ts#resolveEnvProxyAgent calls resolveAmbientNodeProxyAgent (in plugin-sdk/extension-shared), which performs a dynamic import('proxy-agent'). proxy-agent is not a declared dependency of @openclaw/whatsapp, so the dynamic import silently fails in bundled installs:

  • The onError warn path logs Failed to initialize env proxy agent… but it's easy to miss in routine logs.
  • The function returns undefined, so makeWASocket({ agent: undefined }) opens a direct WebSocket connection.
  • That direct wss://mmg.whatsapp.net request times out from inside firewalled networks → 408.

For comparison, the discord and slack extensions already use https-proxy-agent directly (declared as a direct dep), which is why their proxy paths work in the same environments.

Fix

Mirror the discord/slack pattern:

  1. Add https-proxy-agent (^9.0.0) as a direct dependency of @openclaw/whatsapp's package.json.
  2. Replace the dynamic-import-based resolveAmbientNodeProxyAgent call with resolveEnvHttpProxyUrl('https') (already exposed via openclaw/plugin-sdk/infra-runtime → re-exported from infra/net/proxy-env) and construct new HttpsProxyAgent(url) directly. The shared resolver also honors NO_PROXY / lower-vs-upper case priority semantics, matching the discord/slack behavior.

The fetchAgent path (undici dispatcher for media uploads) is unchanged — it still dynamically imports undici, which is already a direct dependency of @openclaw/whatsapp.

Behavior

EnvBeforeAfter
No proxy env varsdirect connection (correct)direct connection (correct)
HTTPS_PROXY=http://… setdirect connection → 408tunneled via HttpsProxyAgent
HTTP_PROXY only setdirect connection → 408tunneled via HttpsProxyAgent (fallback)
Malformed proxy URLfalls back to directfalls back to direct (logged)

Verification

The reporter's manual diff in #72547 confirmed that constructing new HttpsProxyAgent(process.env.HTTPS_PROXY) directly fixes the symptom. This PR formalizes that approach with the project's shared env-proxy resolver and aligns whatsapp with the discord/slack convention.

Refs

  • Closes #72547
  • Related: extensions/slack/src/client-options.ts (template) — same pattern

Changed files

  • extensions/whatsapp/package.json (modified, +1/-0)
  • extensions/whatsapp/src/session.ts (modified, +28/-12)

Code Example

const { version } = await fetchLatestBaileysVersion();
        // the original code ignore the http proxy in terminal
	const agent1 = await resolveEnvProxyAgent(sessionLogger);
	const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent1);
	

	// so force it to read env variable of http proxy, before makeWASocket call
	const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
	const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;

	const sock = makeWASocket({
		auth: {
			creds: state.creds,
			keys: makeCacheableSignalKeyStore(state.keys, logger)
		},
		version,
		logger,
		printQRInTerminal: false,
		browser: [
			"openclaw",
			"cli",
			VERSION
		],
		syncFullHistory: false,
		markOnlineOnConnect: false,
		agent,
		fetchAgent
	});

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

the issue is same to #2153 , but the code affected is no located in ~/.nvm/versions/node/v22.16.0/lib/node_modules/openclaw/dist/extensions/whatsapp/connection-controller-Cxgtxfr6.js It affects the QR code linking of channel whatsapp, specially user was using http proxy to get through China's network firewall

  • openclaw version: 2026.4.24
  • MacOS 26.3.1

the code works after modified as below:

	const { version } = await fetchLatestBaileysVersion();
        // the original code ignore the http proxy in terminal
	const agent1 = await resolveEnvProxyAgent(sessionLogger);
	const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent1);
	

	// so force it to read env variable of http proxy, before makeWASocket call
	const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
	const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;

	const sock = makeWASocket({
		auth: {
			creds: state.creds,
			keys: makeCacheableSignalKeyStore(state.keys, logger)
		},
		version,
		logger,
		printQRInTerminal: false,
		browser: [
			"openclaw",
			"cli",
			VERSION
		],
		syncFullHistory: false,
		markOnlineOnConnect: false,
		agent,
		fetchAgent
	});

Steps to reproduce

  1. (re)link whatsapp to openclaw using QR code to pair the device

Expected behavior

the whatsapp extension should read env varialbe of http_proxy etc, and properly show the QR code from Whatsapp server

Actual behavior

the openclaw configure command says:

Waiting for WhatsApp connection... WhatsApp Web connection ended before fully opening. status=408 Request Time-out WebSocket Error (Client network socket disconnected before secure TLS connection was established) WhatsApp login failed: Error: status=408 Request Time-out WebSocket Error (Client network socket disconnected before secure TLS connection was established)

OpenClaw version

2026.4.24

Operating system

MacOS 26.3.1

Install method

npm global

Model

all

Provider / routing chain

openclaw on local computer

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The issue can be fixed by modifying the code to properly handle HTTP proxy settings when linking WhatsApp to OpenClaw using a QR code.

Guidance

  • The problem seems to be related to the code not respecting the HTTP proxy environment variables, which is necessary for users behind certain network firewalls, such as China's.
  • To fix this, the code needs to be modified to read the HTTP proxy environment variables (HTTP_PROXY, https_proxy, etc.) and use them when creating the WebSocket connection.
  • The provided code modification is a potential solution, which forces the code to read the HTTP proxy environment variables before making the WebSocket connection.
  • Verify that the HTTP_PROXY environment variable is set correctly and that the modified code is being used.

Example

The provided code snippet shows how to modify the makeWASocket call to use the HTTP proxy agent:

const proxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;
const sock = makeWASocket({
  // ...
  agent,
  // ...
});

Notes

This fix assumes that the HTTP_PROXY environment variable is set correctly and that the HttpsProxyAgent class is available. If the issue persists, further debugging may be necessary to determine the root cause.

Recommendation

Apply the provided workaround by modifying the code to read the HTTP proxy environment variables and use them when creating the WebSocket connection. This should fix the issue for users behind certain network firewalls.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

the whatsapp extension should read env varialbe of http_proxy etc, and properly show the QR code from Whatsapp server

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: WhatsApp extension's QR code Connection ignore HTTP/SOCKS5 Proxy as env variable [1 pull requests, 1 comments, 2 participants]