open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.14k stars 600 forks source link

Error 415 when try to send image/video file using proxy #757

Closed roysG closed 4 years ago

roysG commented 4 years ago

Describe the bug When sending image/video i get this error:

Failed to load resource: the server responded with a status of 415 (Unsupported Media Type)

Steps to Reproduce Steps to reproduce the behavior:

  1. send image
  2. see the error.

create() code This is the code you use to create the client. e.g

 const client = await create({
            autoRefresh:true, //default to true
            qrRefreshS:60,
            //useChrome: true,
            executablePath: process.platform === 'linux' ? "/usr/bin/google-chrome" : "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
            headless: process.platform === 'linux' ? true : false,
            proxyServerCredentials:{
                address:this.server.proxy.ip+':'+this.server.proxy.port,
                username:this.server.proxy.username,
                password:this.server.proxy.password
            },
            disableSpins: true,
            sessionId:'session_'+this.ip
        });

Expected behavior The image/video should be sent

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

┌─────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│       (index)       │                                                                    Values                                                                     │
├─────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│     WA_VERSION      │                                                                  '2.2035.14'                                                                  │
│       PAGE_UA       │ 'WhatsApp/2.2029.4 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' │
│ WA_AUTOMATE_VERSION │                                                                    '2.0.8'                                                                    │
│   BROWSER_VERSION   │                                                             'Chrome/81.0.4044.92'                                                             │
└─────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Host (please complete the following information):

smashah commented 4 years ago

@roysG Based on the error the file type was unsupported. Not related to open-wa

roysG commented 4 years ago

I uploaded regular jpg file, I can also send the base64

On Sun, 30 Aug 2020, 20:48 Mohammed Shah notifications@github.com wrote:

Closed #757 https://github.com/open-wa/wa-automate-nodejs/issues/757.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/open-wa/wa-automate-nodejs/issues/757#event-3707494206, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXZDOWJVHOXIWX34AONCW3SDKGF7ANCNFSM4QPT3WXQ .

roysG commented 4 years ago

I also tried with mp4 file and the error was th same, please check that you can send image

I will also paste the bse64 file

On Sun, 30 Aug 2020, 20:51 Liroy Sabah liroy1@gmail.com wrote:

I uploaded regular jpg file, I can also send the base64

On Sun, 30 Aug 2020, 20:48 Mohammed Shah notifications@github.com wrote:

Closed #757 https://github.com/open-wa/wa-automate-nodejs/issues/757.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/open-wa/wa-automate-nodejs/issues/757#event-3707494206, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXZDOWJVHOXIWX34AONCW3SDKGF7ANCNFSM4QPT3WXQ .

smashah commented 4 years ago

@roysG please send the dataurl using pastebin

roysG commented 4 years ago

https://ctxt.io/2/AAAgwLUPFA

On Sun, 30 Aug 2020, 20:54 Mohammed Shah notifications@github.com wrote:

@roysG https://github.com/roysG please send the dataurl using pastebin

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/open-wa/wa-automate-nodejs/issues/757#issuecomment-683450105, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXZDOX4C47EZRLY5LPRDGTSDKG4FANCNFSM4QPT3WXQ .

smashah commented 4 years ago

@roysG This file is working perfectly fine for me.

You will need to share the rest of your code surrounding the sendImage to figure out what's going wrong.

roysG commented 4 years ago

Sorry, wrong image Please try this one: https://ctxt.io/2/AAAgwIMeFA

In case you will paste the base64 here: https://base64.guru/converter/decode/image

You will see the preview of the image without a problem

roysG commented 4 years ago

You can also try this video base64 https://ctxt.io/2/AAAgRAhCFA

roysG commented 4 years ago

The error of 512 is happen even i try to upload video from the whatsapp upload video file I do my tests on browser version: 81.0.4044.92

When i am trying to use with the latest chrome browser, i get these errors:

https://ibb.co/ChN2Q1d

Please tell me, what browser version should i use, what i miss?

A week ago everything was fine

smashah commented 4 years ago

@roysG please use Pastebin in the future. These two files are working fine also.

smashah commented 4 years ago

@roysG Looks like CORS is causing issues again. for some reason this happens sometimes.

I tested on Chrome/84.0.4147.135.

You should upgrade your chrome on your machine or if that doesn't work set bypassCSP to true

https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#bypasscsp

roysG commented 4 years ago

I am using the latest version of chrome: 85.0.4183.83 (Official Build) (64-bit) I added bypassCSP:true

But still i get all the cors error messages

roysG commented 4 years ago

I also tried with version: 84.0.4147.135, Still have the cors problem,

https://ibb.co/x5ftTpF

smashah commented 4 years ago

Related: https://github.com/open-wa/wa-automate-nodejs/issues/503

smashah commented 4 years ago

@roysG Can you try without the proxy

roysG commented 4 years ago

Works! But i need to use proxy, what should i do?

smashah commented 4 years ago

@roysG use a different proxy. Try luminati using this link:

https://luminati.io/?affiliate=ref_5f1b9ae8c7669177abfd9fb8

I've tested and it works fine. Eventually you can upgrade to the residential package

roysG commented 4 years ago

I used in the past in luminati, i need to pay them by usage, they are expensive.

What is the difference if i buy proxy v4 in their company or others?

it should be the same ip v4

roysG commented 4 years ago

I also tried to to it with luminati ip and i get the same error.

roysG commented 4 years ago

The problem is not connect to the type company of proxy, what may be the other options?

smashah commented 4 years ago

Do you need to use a proxy? Apparently some people are using the library just fine with 10+ clients on one machine

roysG commented 4 years ago

So why i have cors erros with proxy, please suggest for me some solution

roysG commented 4 years ago

If you need more information, just tell me

smashah commented 4 years ago

@roysG which proxy service are you using?

roysG commented 4 years ago

proxy6.net - ipv 4

smashah commented 4 years ago

@github-actions run

⚡ Release! ⚡ ```js (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`); })(); ```
smashah commented 4 years ago

Changelog

🚀 Release 2.0.10 (2020-09-01)

smashah commented 4 years ago

@roysG

Please set corsFix to true in your config

https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#corsfix