devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
831 stars 254 forks source link

Error 500 when send large Image (over 5mb) #225

Closed frungillo closed 9 months ago

frungillo commented 9 months ago

With WAHAPLUS istance i tryed do this:

curl -X 'POST' \
  'http://wa.XXXXXXXX.it:1080/api/sendImage' \
  -H 'accept: application/json' \
  -H 'X-Api-Key: XXXXXXXXX' \
  -H 'Content-Type: application/json' \
  -d '{
  "chatId": "39XXXXXXXXXX@c.us",
  "file": {
    "mimetype": "image/jpeg",
    "filename": "filename.jpg",
    "url": "https://www.jemaka.it/img/Genny.jpg"
  },
  "caption": "Prova img da 5mb url",
  "session": "default"
}'

but i receive 500 with this details:

{
  "statusCode": 500,
  "timestamp": "2023-10-18T09:21:41.175Z",
  "exception": {
    "stack": "Error: Evaluation failed: l\n    at ExecutionContext._evaluateInternal (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ExecutionContext.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)\n    at async Client.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:869:28)\n    at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28\n    at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17",
    "message": "Evaluation failed: l",
    "name": "Error"
  },
  "request": {
    "path": "/api/sendImage",
    "method": "POST",
    "body": {
      "chatId": "XXXXXXXXXXXXXXX@c.us",
      "file": {
        "mimetype": "image/jpeg",
        "filename": "filename.jpg",
        "url": "https://www.jemaka.it/img/Genny.jpg"
      },
      "caption": "Prova img da 5mb url",
      "session": "default"
    },
    "query": {}
  },
  "version": {
    "version": "2023.9.7",
    "tier": "PLUS",
    "browser": "/usr/bin/chromium"
  }
}

The image at https://www.jemaka.it/img/Genny.jpg is over 5 mb size, if I'll do the same think with a smaller image, everything work fine. What i'm wrong?

allburov commented 9 months ago

Hi! WhatsApp doesn't accept such big images. You might notice that whatsapp official client just compress the image until like 600KB or so You must either compress it to like less than 1MB file or send it as file via /api/sendFile