WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
4.07k stars 1.38k forks source link

[BUG] Error 403 on downloading media #1094

Open Rubens-Gasparotto opened 1 month ago

Rubens-Gasparotto commented 1 month ago

Describe the bug Sometimes, when trying to download a message using the downloadMediaMessage function, it throws 403 error. I've noticed this happens mostly with PDF files.

To Reproduce Steps to reproduce the behavior:

  1. Receive a message event
  2. Try to download it using the downloadMediaMessage function
  3. Sometimes works, but other times it doesnt

Expected behavior Media should download successfully

Environment (please complete the following information):

Additional context Console error

error:    Unhandled Rejection: AxiosError: Request failed with status code 403
    at settle (/home/node/app/node_modules/axios/dist/node/axios.cjs:1983:12)
    at RedirectableRequest.handleResponse (/home/node/app/node_modules/axios/dist/node/axios.cjs:3033:9)
    at RedirectableRequest.emit (node:events:519:28)
    at RedirectableRequest._processResponse (/home/node/app/node_modules/follow-redirects/index.js:398:10)
    at RedirectableRequest._onNativeResponse (/home/node/app/node_modules/follow-redirects/index.js:91:12)
    at Object.onceWrapper (node:events:634:26)
    at ClientRequest.emit (node:events:519:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:698:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
    at TLSSocket.socketOnData (node:_http_client:540:22)
    at Axios.request (/home/node/app/node_modules/axios/dist/node/axios.cjs:4224:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getHttpStream (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Utils/messages-media.js:320:21)
    at async downloadEncryptedContent (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Utils/messages-media.js:453:21)
    at async downloadMsg (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Utils/messages.js:733:24)
    at async downloadMediaMessage (/home/node/app/node_modules/@whiskeysockets/baileys/lib/Utils/messages.js:693:20)
    at async MediaManagerUtil.downloadMedia (/home/node/app/api/baileys/utils/mediaManager.util.js:19:24)
    at async WatizeMessageFormatUtil.format (/home/node/app/api/baileys/utils/watize-message-format.util.js:187:45)
    at async SessionBaileysConnect.receiveMessage (/home/node/app/api/baileys/layers/base.layer.js:281:34)
lucasdoctype commented 1 week ago

Same problem