waha icon indicating copy to clipboard operation
waha copied to clipboard

[Feature] - Media files fetching doesn't respect Proxy settings - NOWEB, GOWS, WEBJS

Open Horbatenko opened this issue 10 months ago • 3 comments

Describe the bug

We try to launch WAHA in a private VPS, which is isolated from the network and accessible only via Proxy. Once the proxy is set for a session, we can receive and process events, but there is an issue with Media files fetching. The download request to mmg.whatsapp.net:443 fails with a timeout (similar to the behavior with no Proxy set for the regular events in our case)

Version

GET /api/version
{
    "version": "2026.1.1",
    "engine": "NOWEB",
    "tier": "CORE",
    "browser": null,
    "platform": "linux/x64"
}

Steps

To Reproduce Steps to reproduce the behavior:

  1. <VPS, accessible only via proxy>
  2. Open the dashboard
  3. Set up a session, specify Proxy (for some reason, WAHA does not pick up the proxy setting from WHATSAPP_PROXY_SERVER, only a per-session approach works)
  4. Start the session
  5. Send media file to a chat
  6. Open container logs

logs example

{"level":30,"time":1768223520448,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"The message 3B579E966A1D69B7C7E6 has media, downloading it..."}
{"level":20,"time":1768223520448,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":20,"time":1768223531055,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":20,"time":1768223541746,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":20,"time":1768223552635,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":20,"time":1768223563626,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":20,"time":1768223574618,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","msg":"Fetching media from WhatsApp message '3B579E966A1D69B7C7E6'..."}
{"level":50,"time":1768223585110,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","err":{"type":"TypeError","message":"fetch failed: Connect Timeout Error (attempted address: mmg.whatsapp.net:443, timeout: 10000ms)","stack":"TypeError: fetch failed\n    at node:internal/deps/undici/undici:15845:13\n    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at async getHttpStream (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.js:299:22)\n    at async downloadEncryptedContent (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.js:457:21)\n    at async downloadMsg (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:846:24)\n    at async downloadMediaMessage (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:810:20)\n    at async NOWEBEngineMediaProcessor.getMediaBuffer (/app/dist/core/engines/noweb/session.noweb.core.js:2188:17)\n    at async MediaManager.fetchMedia (/app/dist/core/media/MediaManager.js:95:24)\n    at async MediaManager.withRetry (/app/dist/core/media/MediaManager.js:119:20)\n    at async MediaManager.processMediaInternal (/app/dist/core/media/MediaManager.js:55:28)\n    at async MediaManager.processMedia (/app/dist/core/media/MediaManager.js:82:26)\n    at async WhatsappSessionNoWebCore.downloadMediaSafe (/app/dist/core/engines/noweb/session.noweb.core.js:1764:20)\n    at async WhatsappSessionNoWebCore.processIncomingMessage (/app/dist/core/engines/noweb/session.noweb.core.js:1557:27)\ncaused by: ConnectTimeoutError: Connect Timeout Error (attempted address: mmg.whatsapp.net:443, timeout: 10000ms)\n    at onConnectTimeout (/app/node_modules/undici/lib/core/util.js:876:19)\n    at Immediate._onImmediate (/app/node_modules/undici/lib/core/util.js:845:11)\n    at process.processImmediate (node:internal/timers:504:21)"},"msg":"Failed to execute 'Fetching media', tried '5' times"}
{"level":50,"time":1768223585114,"pid":7,"hostname":"c5e84605946f","reqId":480,"session":"default","name":"MediaManager","err":{"type":"TypeError","message":"fetch failed: Connect Timeout Error (attempted address: mmg.whatsapp.net:443, timeout: 10000ms)","stack":"TypeError: fetch failed\n    at node:internal/deps/undici/undici:15845:13\n    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at async getHttpStream (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.js:299:22)\n    at async downloadEncryptedContent (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages-media.js:457:21)\n    at async downloadMsg (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:846:24)\n    at async downloadMediaMessage (file:///app/node_modules/@adiwajshing/baileys/lib/Utils/messages.js:810:20)\n    at async NOWEBEngineMediaProcessor.getMediaBuffer (/app/dist/core/engines/noweb/session.noweb.core.js:2188:17)\n    at async MediaManager.fetchMedia (/app/dist/core/media/MediaManager.js:95:24)\n    at async MediaManager.withRetry (/app/dist/core/media/MediaManager.js:119:20)\n    at async MediaManager.processMediaInternal (/app/dist/core/media/MediaManager.js:55:28)\n    at async MediaManager.processMedia (/app/dist/core/media/MediaManager.js:82:26)\n    at async WhatsappSessionNoWebCore.downloadMediaSafe (/app/dist/core/engines/noweb/session.noweb.core.js:1764:20)\n    at async WhatsappSessionNoWebCore.processIncomingMessage (/app/dist/core/engines/noweb/session.noweb.core.js:1557:27)\ncaused by: ConnectTimeoutError: Connect Timeout Error (attempted address: mmg.whatsapp.net:443, timeout: 10000ms)\n    at onConnectTimeout (/app/node_modules/undici/lib/core/util.js:876:19)\n    at Immediate._onImmediate (/app/node_modules/undici/lib/core/util.js:845:11)\n    at process.processImmediate (node:internal/timers:504:21)"},"msg":"Error processing media for message '3B579E966A1D69B7C7E6'"}

Expected behavior

Media assets get downloaded

Additional context

Our env settings example

WHATSAPP_PROXY_SERVER=host:port

HTTP_PROXY=http://host:port
HTTPS_PROXY=http://host:port
NO_PROXY=...

...
WAHA_MEDIA_STORAGE=LOCAL
WHATSAPP_FILES_LIFETIME=3600  # 1 hour
WHATSAPP_FILES_FOLDER=/app/.media

WHATSAPP_DOWNLOAD_MEDIA=true

Horbatenko avatar Jan 12 '26 13:01 Horbatenko

yeah, need to add additional settings to use all proxies for all networks connections 👍

Let's see how many patron:PLUS and patron:PRO supporters needs the feature and prioritize it based on that.

Comment with "+1" if you need it!

devlikepro avatar Jan 12 '26 16:01 devlikepro

@devlikepro, thanks for the consideration

Media files fetching doesn't respect Proxy settings ... use all proxies for all networks connections

though maybe this is something we should go with, as a safe bet? or at least mention the current behavior in the docs

as we don't know how people might use their proxies (to avoid WhatsApp limitations, enhance security, monitor traffic, etc), and having WHATSAPP_PROXY_SERVER setting applied only for part of the connections, might not be something users expect

Horbatenko avatar Jan 13 '26 09:01 Horbatenko

and talking about our scenario, we also have this bit of a problem

  1. Set up a session, specify Proxy (for some reason, WAHA does not pick up the proxy setting from WHATSAPP_PROXY_SERVER, only a per-session approach works)

do you have any guesses what might cause the WHATSAPP_PROXY_SERVER setting to not be applied and only the per-session ones be respected?

we've checked the code of WAHA Core and everything seemed ok but we still can't make the global proxy setup work

Horbatenko avatar Jan 13 '26 09:01 Horbatenko