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

Can't login with Multidevice on linux machine #2491

Closed siriostar89 closed 2 years ago

siriostar89 commented 2 years ago

Hello everyone, as you can read from the title I can't do any multidevice login on linux! I was developing an "home-bot" and I started coding on windows and it works fine with multidevice, but when I move this on my home server (arch linux) when I scan the qr code on my phone after some wait, whatsapp say that can't login and control internet access of the phone and scan again the qr (useless to say that do not work) and on terminal I get:

QR scan took too long. Session Timed Out. Shutting down. Consider increasing qrTimeout config variable: https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#qrtimeout
Error while terminating browser PID. You can just ignore this, as the process has most likely been terminated successfully already: kill ESRCH
Error: QR Timeout

the strange thing it's that works without multidevice. I use docker on my server and I even used your docker image of easyapi and I have the same problem! What can I do to understand what's going on?

smashah commented 2 years ago

Can you show what you've been trying so far including your config

siriostar89 commented 2 years ago

I used the "starter template" for test

const wa = require('@open-wa/wa-automate');

wa.create({
  sessionId: "COVID_HELPER",
  multiDevice: true, //required to enable multiDevice support
  authTimeout: 60, //wait only 60 seconds to get a connection with the host account device
  blockCrashLogs: true,
  disableSpins: true,
  headless: true,
  hostNotificationLang: 'PT_BR',
  logConsole: false,
  popup: true,
  qrTimeout: 0, //0 means it will wait forever for you to scan the qr code
}).then(client => start(client));

function start(client) {
  client.onMessage(async message => {
    if (message.body === 'Hi') {
      await client.sendText(message.from, '👋 Hello!');
    }
  });
}

So nothing special, the problem it's the same! On windows works as expected, on arch linux and docker container, it only works without multidevice! There's anything that I can do to get somekind of log?

smashah commented 2 years ago

It already outputs a lot of logs which you should've really pasted all of in the original post + used the issue template.

Please run the CLI and report back with all of the log output

npx @open-wa/wa-automate --disable-spins --multi-device --debug --session-id MD_TEST --socket

siriostar89 commented 2 years ago

Here's the log:

npx @open-wa/wa-automate --disable-spins --multi-device --debug --session-id MD_TEST --socket
- MD_TEST_STARTUP
- DEBUG - flags: {"sessionId":"MD_TEST","disableSpins":true,"multiDevice":true,"debug":true,"socket":true,"noApi":false,"port":8002,"host":"localhost","ef":["qr","STARTUP"],"allowSessionDataWh":false,"generateApiDocs":true,"sessionDataOnly":false,"skipSavePostmanCollection":false,"stats":false,"preAuthDocs":false,"noKillOnLogout":false,"cors":false,"emitUnread":false,"popup":false}
- DEBUG - env vars: {}
- Launching EASY API
- Selected port is free
- Generating Swagger Spec
- Postman collection generated: open-wa-MD_TEST.postman_collection.json
- API collections (swagger + postman) generated successfully
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓┃                                                                                                ┃┃   @open-wa/wa-automate                                                                         ┃┃   💬 🤖 The most reliable NodeJS whatsapp library for chatbots with advanced features.         ┃┃   Version: 4.30.11                                                                             ┃┃   Check out the latest changes: https://github.com/open-wa/wa-automate-nodejs#latest-changes   ┃┃                                                                                                ┃┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
- Starting
- Version: 4.30.11
- Initializing WA
- It is recommended to set useChrome: true or use the --use-chrome flag if you are experiencing issues with Multi device support
- Launching Browser
- MD Enabled, turning off incognito mode.
- Data dir: ./_IGNORE_MD_TEST
- Browser launched: 1091ms
- Setting Up Page
- Loading session data
- No session data file found for session : MD_TEST
- No session data detected. Opting in for MD.
- Make sure to keep the session alive for at least 5 minutes after scanning the QR code before trying to restart a session!!
- Pre page launch setup complete: 78ms
- Navigating to WA
- Page loaded in 5564ms: 200
- Page loaded
- Base inject: 302ms
- WAPI inject: 163ms
- Checking session integrity
- Session integrity check failed, trying again... 2
- WAPI inject: 912ms
- Checking session integrity
- Debug info: {
  "WA_VERSION": "2.2202.12",
  "PAGE_UA": "WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
  "WA_AUTOMATE_VERSION": "4.30.11",
  "BROWSER_VERSION": "HeadlessChrome/98.0.4758.0",
  "OS": "Linux 5.15",
  "START_TS": 1644224735673
}
- Use this easy pre-filled link to report an issue: https://github.com/open-wa/wa-automate-nodejs/issues/new?template=bug_report.yaml&d_info=%7B%0A%20%20%22WA_VERSION%22:%20%222.2202.12%22,%0A%20%20%22WA_AUTOMATE_VERSION%22:%20%224.30.11%22,%0A%20%20%22BROWSER_VERSION%22:%20%22HeadlessChrome/98.0.4758.0%22,%0A%20%20%22START_TS%22:%201644224735673,%0A%20%20%22LATEST_VERSION%22:%20true,%0A%20%20%22CLI%22:%20true%0A%7D&enviro=-%20OS:%20Linux%205.15%0A-%20Node:%2017.3.0%0A-%20npm:%208.4.1&labels=CLI,MD
- Time to injection: 10061ms
- Injecting api
- Session integrity check failed, trying again... 3
- Base inject: 162ms
- WAPI inject: 2837ms
- Checking session integrity
- WAPI inject: 2729ms
- Checking session integrity
- Session integrity check passed
- Session integrity check passed
- Launch inject: 4321ms
- WAPI injected
- Authenticating
- Launch inject: 7242ms
- Authenticate to continue
- First QR: 49466 ms

Deleted QR code

- QR scan took too long. Session Timed Out. Shutting down. Consider increasing qrTimeout config variable: https://open-wa.github.io/wa-automate-nodejs/interfaces/configobject.html#qrtimeout
Error while terminating browser PID. You can just ignore this, as the process has most likely been terminated successfully already: kill ESRCH
Error: QR Timeout
    at /home/marco/.npm/_npx/21fe510f43113ad2/node_modules/@open-wa/wa-automate/dist/controllers/initializer.js:289:27
    at Generator.next (<anonymous>)
    at fulfilled (/home/marco/.npm/_npx/21fe510f43113ad2/node_modules/@open-wa/wa-automate/dist/controllers/initializer.js:24:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error while terminating browser PID. You can just ignore this, as the process has most likely been terminated successfully already: kill ESRCH
- MD_TEST_STARTUP
- Error QR Timeout Error: QR Timeout
smashah commented 2 years ago

Ok try again with --qr-timemout 0

siriostar89 commented 2 years ago

Same result as above :(

smashah commented 2 years ago

@alifax89 have you considered using ubuntu instead of arch?

siriostar89 commented 2 years ago

Well if I knew that would work, yes I would consider it, maybe the only test that I can do, is to install ubuntu server on virtualbox and test there if it works!

smashah commented 2 years ago

Yeh do that because all the machines I run it on are u until based and I know the OS is not a blocker there.

Also, are you building homebot via node-red? If not why not?

smashah commented 2 years ago

There's no arch linux droplet on DO and I know it's famously complicated to spin up so unless I can SSH into your machine I'm considering arch a no-go

siriostar89 commented 2 years ago

Because I never used node-red 😄 Plus, I use HomeAssistant to control my house and sometimes I use python to interact with other devices in my house! I wanted to integrate whatsapp to interact with those devices and get results back! But anyway, when I have some free time I will try ubuntu and report it back! A last question... If I will succesfully login with ubuntu, can I move the folder IGNORE[session_name] to my server? or will not work?

smashah commented 2 years ago

Not sure where you heard of home bot but the node red setup literally sits inside home assistant. You can easily connect home assistant to open wa via node red. Genie handles most of the conversational/AI stuff locally (that too is also connected to home assistant) and you can make custom flows easily. If you join the discord I can show you exactly how to set it up and extend the functionality in our dedicated home bot channel. To join the discord just click on the discord badge in this repo's README.

The IGNORE folder is essential to enable the Library to reauthenticate the session.

siriostar89 commented 2 years ago

Just a little update, I made a test on Ubuntu server and it works! Plus, I moved the IGNORE folder from ubuntu to my arch server and launched the same script and it works (I don't need to reautenticate) so at least for now, I don't need to reinstall my home server!!!! 😆 But would be nice to know what's happen on arch that cause the login to fail (at least for MD)

smashah commented 2 years ago

@alifax89 can you share your config please? It's quite odd (in a very good way) that you were able to migrate the ignore folder and successfully reauthenticate

siriostar89 commented 2 years ago

Sure, here's the config I used:

    sessionId: 'mysession', //name of session
    multiDevice: true, // for version not multidevice use false.(default: true)
    useChrome: true,
    blockCrashLogs: true,
    disableSpins: true,
    headless: true,
    chromiumArgs: [
        "--disable-gpu",
        "--disable-dev-shm-usage",
        "--disable-setuid-sandbox",
        "--no-sandbox"
    ]

Well I don't think that it's so "odd", in a logic way the base OS is linux, so I wanted to try to move the ignore folder to my arch server, even because the IGNORE folder it's the equivalent of the Profile folder of Firefox (where are stored cookies, settings, etc), surely do not work from windows to linux. But would be nice to understand what's block the autentication process on Arch linux...

smashah commented 2 years ago

thanks for the details.

Closing for now thanks