pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.05k stars 3.58k forks source link

Timeout Error After scanning the QR code #1099

Closed Az-r-ow closed 2 years ago

Az-r-ow commented 2 years ago

Bug description

A clear and concise description of what the bug is. After scanning the qr code, the client initiate normally and then 45s later I get this following error :

/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:513
            const timeoutError = new Errors_js_1.TimeoutError(`waiting for ${options.title} failed: timeout ${options.timeout}ms exceeded`);
                                 ^

TimeoutError: waiting for selector `canvas` failed: timeout 45000ms exceeded
    at new WaitTask (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:513:34)
    at DOMWorld.waitForSelectorInPage (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:424:26)
    at Object.internalHandler.waitFor (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77)
    at DOMWorld.waitForSelector (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:317:29)
    at Frame.waitForSelector (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51)
    at Page.waitForSelector (/home/pi/software-projects/whatsapp-bot/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2313:33)
    at Timeout.getQrCode (/home/pi/software-projects/whatsapp-bot/node_modules/whatsapp-web.js/src/Client.js:143:28)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Reproduction steps

Steps to reproduce the behavior:

  1. Start the program
  2. Scan the qr code
  3. Wait

Expected behavior

The client to connect and to stay connected the whole time while I'm running the program.

Environment (please complete the following information):

WhatsApp

Library

Other

Az-r-ow commented 2 years ago

I forgot to add the whatsapp web version which is : 2.2147.16

wahyuade commented 2 years ago

if you have a lot of chat on your phone, Whatsapp web needs more time to sync. in my case, it was solved by bumping the authTimeoutMs to 900000 (15 minutes). the docs is showed here

so you can implement it using:

new Client({
    authTimeoutMs: 900000,
    ...

hope it can solve your issue.

Yuri-Lima commented 2 years ago

@Az-r-ow let me know if that solution has worked for you. Thanks

Az-r-ow commented 2 years ago

@wahyuade @tuyuribr, it worked ! Thanks.