Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On 'ready' is not fired #2458

Closed
1 task done
TheMacros opened this issue Aug 29, 2023 · 42 comments
Closed
1 task done

On 'ready' is not fired #2458

TheMacros opened this issue Aug 29, 2023 · 42 comments
Labels
bug Something isn't working

Comments

@TheMacros
Copy link

TheMacros commented Aug 29, 2023

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.

@TheMacros TheMacros added the bug Something isn't working label Aug 29, 2023
@TheMacros
Copy link
Author

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.

@frnndwrms
Copy link

frnndwrms commented Aug 29, 2023 via email

@AndersonVale
Copy link

same here. version 1.22.1

@MatheusOliveira-dev
Copy link

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

@pecintamantan
Copy link

pecintamantan commented Aug 30, 2023

same here i think my vps is broken but not :v

@neckell
Copy link

neckell commented Aug 30, 2023

same here. I tried on Linux (WSL) using docker and localhost, worked fine. But on production (azure) somehow it's not working 1.22.1 version. And it started happing just before updating from stable 1.21.0 version

@YagoRosa
Copy link

Same here on chrome.

@MarlonRibeirodeMelo
Copy link

I have the same problem, using ubuntu 18, it stopped working completely

@rogerthedeveloper
Copy link

Me too, the same behavior here, when expecting the ready event to be fired

@neckell
Copy link

neckell commented Aug 30, 2023

1.22.2-alpha.0 works fine

@yan043
Copy link

yan043 commented Aug 31, 2023

it's working for me in version 1.22.1
image

@EpicJosch
Copy link

same error

@EpicJosch
Copy link

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

thanks man! this really fixes the issue!

@dev-dfBueno
Copy link

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

Pra mim não rolou não :'(

@ItzFerr
Copy link

ItzFerr commented Aug 31, 2023

same here, it solved when i changed to 1.22.2-alpha.0

@dev-dfBueno
Copy link

mesmo aqui, resolveu quando mudei para 1.22.2-alpha.0

Como que muda?
Pode me ajudar?

@EdnaldoTaurino
Copy link

tbm quero saber como muda

@max-programming
Copy link

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

Thanks!
But I got this new error
image

@max-programming
Copy link

max-programming commented Aug 31, 2023

Also @ItzFerr I got this error when switching to the alpha

image

@thiagootero
Copy link

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']"

@thiagootero
Copy link

tbm quero saber como muda

Altere o arquivo package.json, alterando a versão do whatsapp web. Depois, rode o comando npm install

@areumtecnologia
Copy link

npm i whatsapp-web.js@1.22.2-alpha.0 --save

@YagoRosa
Copy link

YagoRosa commented Sep 1, 2023

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.

@andresmv94
Copy link

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.

same here

@YagoRosa
Copy link

YagoRosa commented Sep 2, 2023

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.

Alright, in issue #2439 I found a comment from @joulgs about uninstalling whatsapp-web.js

npm unistall whatsapp-web.js -S

and then add it to the package.json file in the dependencies

"whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_8"

After changing just run the code

npm install

the client came back, it shows that whatsapp was connected but it gives an error

Error: Evaluation failed: Error: wid error: invalid wid

/workspaces/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));

does anyone have any suggestions?

I will keep looking for a solution.

@YagoRosa
Copy link

YagoRosa commented Sep 2, 2023

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.

Alright, in issue #2439 I found a comment from @joulgs about uninstalling whatsapp-web.js

npm unistall whatsapp-web.js -S

and then add it to the package.json file in the dependencies

"whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_8"

After changing just run the code

npm install

the client came back, it shows that whatsapp was connected but it gives an error

Error: Evaluation failed: Error: wid error: invalid wid

/workspaces/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221 throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));

does anyone have any suggestions?

I will keep looking for a solution.

I don't know what could have happened but apparently the authenticator was causing some conflict.

With me I used the following code for authentication :

const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth()
});

I changed to :

const { Client } = require('whatsapp-web.js');
const client = new Client();

Now it's working perfectly, I don't know what could have caused the bug that was happening to me but when I removed the authenticator it started working normally again, all messages are being sent and the bot responds perfectly.

@granaber
Copy link

granaber commented Sep 2, 2023

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

@SonuSubhadip
Copy link

SonuSubhadip commented Sep 5, 2023

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

@dev-dfBueno
Copy link

Alterar este arquivo resolveu o problema para você? Função para mim: devolver

Pra mim não rolou não :'(

Substitua em 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"]';

pára

const INTRO_IMG_SELECTOR = "[data-icon='chat']"

Aqui resolveu, alterei dessa forma e alterei também o package pra Alpha.. Obrigado!!

@almacres10
Copy link

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?

1 similar comment
@almacres10
Copy link

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?

@neckell
Copy link

neckell commented Sep 7, 2023

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",

@leodutra
Copy link

This fix worked for me #2485

@burakerenel
Copy link

This fix worked for me #2485

mine too

@fpiantoni
Copy link

The error is still happening, the new fix is:
const INTRO_IMG_SELECTOR = '[data-icon='new-chat']';

On the Client.js file from the Package

@neckell
Copy link

neckell commented Sep 28, 2023

@fpiantoni did you check on the repo i quoted? I am not quite sure about new-chat, i tested it and didn't work for me

@fpiantoni
Copy link

@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

@neckell
Copy link

neckell commented Sep 28, 2023

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

@LucasMonteiroi
Copy link

image

This works for me, just updated the package version, this is my sample code:

const qrcode = require('qrcode-terminal');
const { Client, LocalAuth } = require('whatsapp-web.js');

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.on('message', (msg) => {
  if (msg.body == '!ping') {
    msg.reply('pong');
  }
});

client.initialize();

@alechkos alechkos closed this as completed Dec 2, 2023
@learntheropes
Copy link

@alechkos which is the commit of this fix?

@alechkos
Copy link
Collaborator

alechkos commented Dec 2, 2023

@learntheropes

npm i github:pedroslopez/whatsapp-web.js#main

@learntheropes
Copy link

@alechkos yes, but I can't find how this has been fixed on the repo.

Repository owner locked and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests