#21837: feat(whatsapp): add HTTP_PROXY/HTTPS_PROXY support for Baileys WebSocket
channel: whatsapp-web
size: XS
Cluster:
Reaction Event Handling Enhancements
## Summary
Baileys WebSocketClient does not automatically use `HTTP_PROXY`/`HTTPS_PROXY`. When running in restricted regions (e.g. behind firewall) where Meta endpoints are unreachable, the connection fails with ETIMEDOUT/408.
## Changes
- Pass `HttpsProxyAgent` to `makeWASocket` when `HTTP_PROXY` or `HTTPS_PROXY` is set
- Set `connectTimeoutMs` to 60s to accommodate slower proxy connections
## Usage
Set `HTTP_PROXY` or `HTTPS_PROXY` (e.g. `http://127.0.0.1:8080`) before starting the gateway. The WhatsApp Baileys connection will route through the proxy.
## Testing
Verified on a server in a restricted region: WhatsApp WebSocket successfully connects via local HTTP proxy (sing-box) to Meta endpoints.
Made with [Cursor](https://cursor.com)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds HTTP/HTTPS proxy support for WhatsApp WebSocket connections via Baileys by passing `HttpsProxyAgent` when `HTTP_PROXY` or `HTTPS_PROXY` environment variables are set.
- Imports `HttpsProxyAgent` from `https-proxy-agent` package (already present in dependencies)
- Reads proxy URL from `HTTPS_PROXY` or `HTTP_PROXY` environment variables
- Conditionally passes agent to `makeWASocket` when proxy is configured
- Sets `connectTimeoutMs` to 60 seconds for proxy connections
<h3>Confidence Score: 3/5</h3>
- This PR is safe to merge with one logic fix needed
- The implementation correctly adds proxy support, but unintentionally changes the connection timeout for all users (not just those using proxies), which could affect existing behavior
- Pay close attention to `src/web/session.ts` line 121-126 - the timeout change affects all users
<sub>Last reviewed commit: 4cb65bb</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7287: feat(whatsapp): expose group admin functions
by balthazar-bot · 2026-02-02
74.6%
#12894: feat(whatsapp): add reaction notifications support
by ekson73 · 2026-02-09
72.2%
#17326: fix(whatsapp): group composing indicator, echo prevention, and pres...
by globalcaos · 2026-02-15
71.8%
#8224: feat(whatsapp): extract @mentions into dedicated module
by zurizuriaria · 2026-02-03
71.6%
#20399: feat(whatsapp): surface inbound reaction events to agent session
by andrewchen · 2026-02-18
70.9%
#3071: fix: WhatsApp 515 error retry not triggering
by rabsef-bicrym · 2026-01-28
70.8%
#8705: feat(whatsapp): add viewOnce support for ephemeral media
by ndohuu · 2026-02-04
70.2%
#16608: feat(whatsapp): resolve outbound @mentions to clickable WhatsApp me...
by lucasmpramos · 2026-02-14
69.9%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
69.5%
#16923: fix(web): resolve stale socket race condition in WhatsApp auto-reply
by dorukardahan · 2026-02-15
69.3%