Wa-automate-nodejs: Send image/file not working.

Created on 21 May 2020  Â·  9Comments  Â·  Source: open-wa/wa-automate-nodejs

Describe the bug
Trying to send Images or Files not working. No error thrown but setting logConsoleErrors: true we can see the errors below:

```
ConsoleMessage {
_type: 'error',
_text: "Access to XMLHttpRequest at 'https://mmg-fna.whatsapp.net/mms/image/v9RBq0lmmt-BiPQX6XBOkCuY1kbGO-H2Ve5qMKaG66c=?auth=AWR60vm61WxcOCpYHSPtNiWSftrBAicMc3PnnPfgrmpgbdZA3drgzru3DmA&token=v9RBq0lmmt-BiPQX6XBOkCuY1kbGO-H2Ve5qMKaG66c%3D&resume=1' from origin 'https://web.whatsapp.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.",
_args: [],
_location: { url: 'https://web.whatsapp.com/', lineNumber: undefined }
}
ConsoleMessage {
_type: 'error',
_text: 'Failed to load resource: net::ERR_FAILED',
_args: [],
_location: {
url: 'https://mmg-fna.whatsapp.net/mms/image/v9RBq0lmmt-BiPQX6XBOkCuY1kbGO-H2Ve5qMKaG66c=?auth=AWR60vm61WxcOCpYHSPtNiWSftrBAicMc3PnnPfgrmpgbdZA3drgzru3DmA&token=v9RBq0lmmt-BiPQX6XBOkCuY1kbGO-H2Ve5qMKaG66c%3D&resume=1',
lineNumber: undefined
}
}

**Steps to Reproduce**
Steps to reproduce the behavior:
1. Open connection
2. Receive message
3. Send a message using sendImage, sendFile or sendFileFromUrl
4. Image does not get there

**create() code**
This is the code you use to create the client. e.g
```javascript
create({
  sessionId: `mySesionId`,
  headless: true,
  autoRefresh: false,
  blockCrashLogs: true,
  cacheEnabled: false,
  throwErrorOnTosBlock: true,
  logConsole: true,
  logConsoleErrors: true,
  useChrome: true,
  qrLogSkip: true,
  disableSpins: true
}).then((client) => {
  client.onMessage(async (message) => {
    await client.sendFileFromUrl(
      message.sender.id,
      "https://media.zappo.net.br/uploads/acc-1/pizzaria-agua-e-farinha/catalog/imagens-do-alimento-diferente-33752241.jpg",
      "imagens-do-alimento-diferente-33752241.jpg",
      "Test Image"
    )
  })
})

Expected behavior
The image to be sent

DEBUG INFO
This is the info printed to the console when you start your app. It should look like this

Debug Info {
  WA_VERSION: 2.2019.8,
  PAGE_UA: 'WhatsApp/2.2019.8 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36' ,
  WA_AUTOMATE_VERSION: 1.9.33,
  BROWSER_VERSION: HeadlessChrome/83.0.4103.61
}

Screenshots
If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots

Host (please complete the following information):

  • OS: Same on MAC OS and Docker image (node 12.13.0)

Additional context
On Mac OS, running with headless: false, it works...

All 9 comments

@sandro-salles can you try with the following chrome arg: --disable-web-security

@github-actions run


âš¡ Release! âš¡

(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// Config
const gitUserEmail = "github-actions[bot]@users.noreply.github.com";
const gitUserName = "github-actions[bot]";

exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`);
exec(`git config --global user.email "${gitUserEmail}"`);
exec(`git config --global user.name "${gitUserName}"`);
exec(`npm i`);
exec(`npm run release-ci`);

//comment on the issue
var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString();

    await postComment(result);

//create changelog image
exec(`npm run release-image`);
exec(`git commit -a -m 'updated release-image'`);
exec(`git push --force`);
  })();

Changelog

🚀 Release 1.9.34 (2020-05-21)

  • Release 1.9.34 65f0701
  • feature: added bypassCSP in ConfigObject 2e4a9ca

@sandro-salles please update to the latest version and use bypassCSP: true in the config object. Let me know if it fixes the issue.

Hello, the problem is not with @wa-automate, but with Google Chrome version 83.0.4103.61-1. I tested with "bypassCSP: true" and sendfile did not work.

@smashah i think @barkerpedro is right. the previous chrome version was working fine, this one is not working, even with bypassCSP: true set... is it possible to rollback to that version?

Ok will roll it back

@sandro-salles @barkerpedro I decided not to roll back just yet. Instead, you can manually set the browserRevision.

Read how to implement it here:
https://github.com/open-wa/wa-automate-nodejs/issues/474#issuecomment-632658220

The last version of puppeteer had browserRevision:"737027"

Please try this and let me know if it worked.

Thanks

Yes @smashah , It is working after setting up the browserRevision configuration.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bubaew95 picture bubaew95  Â·  6Comments

blackchineykh picture blackchineykh  Â·  4Comments

sandro-salles picture sandro-salles  Â·  4Comments

phantom-limb picture phantom-limb  Â·  5Comments

jersonjunior picture jersonjunior  Â·  6Comments