whatsapp-web.js: On 'ready' is not fired

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I’m trying to create a very basic app that handles incoming messages from WhatsApp.

The code generates a QR code successfully, but when I scan it with WhatsApp (link device) with an iOS or Android app nothing happens. The QR code is scanned successfully and the linked device (browser) appears on my mobile device. However, in the console, I didn’t receive ‘Client is ready!’ message or any other message (like ‘Client is authenticated!’ or ‘Client is auth_failure!’) - absolutely nothing. When I disconnect the device I also don’t receive the message ‘Client is disconnected!’. Also, I have no exceptions.

Expected behavior

I’m expecting the on(‘ready’) should fire when I scan the QR code and on(‘disconnected’) should be fired when device is removed

Steps to Reproduce the Bug or Issue

There are no steps to reproduce.

Relevant Code

import waweb from "whatsapp-web.js";
import qrcode from 'qrcode-terminal';

const { Client, LocalAuth } = waweb;

const client = new Client({
    puppeteer: {
        args: [
            '--no-sandbox',
            '--disable-setuid-sandbox'
        ],
    }
});

client.on('qr', qr => {
    qrcode.generate(qr, {small: true});
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('disconnected', () => {
    console.log('Client is disconnected!');
});

client.on('authenticated', () => {
    console.log('Client is authenticated!');
});

client.on('auth_failure', () => {
    console.log('Client is auth_failure!');
});

client.initialize();

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Ubuntu Linux 18.04 Phone: iOS or Android whatsapp-web.js: 1.22.1 WhatsApp Web version: 2.2335.9 Node: 16.15.1

Additional context

I have another app (that uses whatsapp-web) running on the same server. It works fine.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 9
  • Comments: 42

Most upvoted comments

Did changing this file fix the problem for you? It worked for me: fix

same here with latest version

El mar, 29 ago 2023 a la(s) 13:21, TheMacros @.***) escribió:

Just tested the same script with the same version (1.22.1) on macOS - the same result. If I run it with puppeteer.headless = false on macOS - I see that the authorization process is working in Chromium (so in the Chromium browser I see my account authorized), but still nothing I can see in the script output.

I’ve also tried the 1.22.2-alpha.0 - this version works fine! So I’ll stay on the alpha for now. But the question is how the 1.22.1 is working on my other project.

— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/2458#issuecomment-1697769556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQBBZJSBX6WN5YXQ3UP7DTXXYJJXANCNFSM6AAAAAA4DESGSE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

– Fernando Wermus.

Los contenidos de este mensaje, y los archivos adjuntos, son de carácter confidencial. Si ud. no es el legitimo destinatario de este mensaje, avise inmediatamente al remitente y borre este mensaje. Cualquier distribución o divulgación no autorizada de este mensaje y sus archivos asociados está prohibida. Por favor infórmenos inmediatamente y destruya el original o cualquier impresión del mismo.

Important Note: This e-mail (including any attachments) is confidential and intended only for the use of the addressee (s) named herein. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original e-mail and any printouts.

it’s working for me in version 1.22.1 image

1.22.2-alpha.0 works fine

This soluction is change to version alpha, 1.22.1 Not working ! image

1st npm uninstall whatsapp-web.js 2nd npm install whatsapp-web.js 3rd Goto > node_modules > whatsapp-web.js > src > client.js > Replace const INTRO_IMG_SELECTOR = ‘[data-testid=“intro-md-beta-logo-dark”], [data-testid=“intro-md-beta-logo-light”], [data-asset-intro-image-light=“true”], [data-asset-intro-image-dark=“true”]’; With const INTRO_IMG_SELECTOR = “[data-icon=‘chat’]”; Enjoy ❤️ 262662891-b952aeac-d75b-47f5-94a2-ee8317281b6b

i still havent found the solution for this, i have try to change the script in Client.js and still the client ready doesnt show up. I have updated the package to whatsapp-web.js 1.22.2-alpha.0 and still doesnt worked. Any other solution?

You should either implement the fix the guys found out on this issue or wait for the release of a new patch version. For implementing the fix, you need to fork the repo and create a new one.

For instance, I will leave here my repo with the corresponding bugfix (working) in case any other want it until stable release come out: https://github.com/neckell/whatsapp-web.js This repo contains whatsapp-web.js@1.22.2-alpha.0 + the ready fix You can temporarily change your package json as follows:

"whatsapp-web.js": "github:neckell/whatsapp-web.js",

Did changing this file fix the problem for you? It worked for me: fix

thanks man! this really fixes the issue!

I added a new state “Synced” that’s fired when a syncronization between mobile phone and instance is complete. It’s not official, it’s up for my needs

@neckell let me check it. I just found that in another reponse, tested it and worked. Let me pull your package and test it. I will keep you updated

This fix worked for me #2485

mine too

Alterar este arquivo resolveu o problema para você? Funcionou para mim: consertar

Pra mim não rolou não 😢

Replace in src/Client.js

const INTRO_IMG_SELECTOR = ‘[data-testid=“intro-md-beta-logo-dark”], [data-testid=“intro-md-beta-logo-light”], [data-asset-intro-image-light=“true”], [data-asset-intro-image-dark=“true”]’;

to

const INTRO_IMG_SELECTOR = “[data-icon=‘chat’]”

I updated to version whatsapp-web.js@1.22.2-alpha.0

I changed the code :

const INTRO_IMG_SELECTOR = ‘[data-testid=“intro-md-beta-logo-dark”], [data-testid=“intro-md-beta-logo-light”], [data-asset-intro-image-light =“true”], [data-asset-intro-image-dark=“true”]’;

for

const INTRO_IMG_SELECTOR = ‘[data-icon=‘chat’]’;

It still didn’t work, and now the QR code doesn’t even appear for me to scan with my cell phone.

does anyone have any suggestions?

I’ll keep looking to see if I find a solution.

Alterar este arquivo resolveu o problema para você? Funcionou para mim: consertar

Pra mim não rolou não 😢

Replace in src/Client.js

const INTRO_IMG_SELECTOR = ‘[data-testid=“intro-md-beta-logo-dark”], [data-testid=“intro-md-beta-logo-light”], [data-asset-intro-image-light=“true”], [data-asset-intro-image-dark=“true”]’;

to

const INTRO_IMG_SELECTOR = “[data-icon=‘chat’]”