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.21k stars 3.63k forks source link

Client does not reach the 'ready' event #2547

Closed whoisdon closed 1 year ago

whoisdon commented 1 year ago

Is there an existing issue for this?

Describe the bug

image

I am facing an issue with the WhatsApp Web client when using the whatsapp-web.js library. After configuring the client as per the instructions and adding event handlers for 'qr', 'ready', and 'message', I expected the 'ready' event to be triggered as soon as the client was ready for use, displaying the message "Client is ready!" in the console. However, even after a successful connection to WhatsApp Web, the 'ready' event is not triggered, and the expected message is not displayed.

Expected behavior

I expected the WhatsApp Web client to connect and return the message "Client is ready!" when it was ready for use.

Steps to Reproduce the Bug or Issue

Imported whatsapp-web.js into my project. Set up a client using the following code:

import WABot, { Client } from 'whatsapp-web.js';
import qrcode from 'qrcode-terminal';

const client = new Client({
    authStrategy: new WABot.LocalAuth(),
    puppeteer: {
        executablePath: './chrome/linux-117.0.5938.92/chrome-linux64/chrome',
        args: ['--no-sandbox']
    }
});

Added event handlers for 'qr', 'ready', and 'message'.

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

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

client.on('message', message => {
    console.log(message)
    if(message.body === '!ping') {
        message.reply('pong');
    }
});

Initialized the client with client.initialize().

Relevant Code

import WABot, { Client } from 'whatsapp-web.js';
import qrcode from 'qrcode-terminal';

const client = new Client({
    authStrategy: new WABot.LocalAuth(),
    puppeteer: {
        executablePath: './chrome/linux-117.0.5938.92/chrome-linux64/chrome',
        args: ['--no-sandbox']
    }
});

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

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

client.on('message', message => {
    console.log(message)
    if(message.body === '!ping') {
        message.reply('pong');
    }
});

client.initialize();

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

OS: Ubuntu OS CellPhone: Android

This issue is affecting my ability to programmatically interact with the WhatsApp Web client.

Additional context

It's worth noting that a friend of mine also experienced the same issue on their computer, so it doesn't appear to be isolated to my environment.

mbnaj commented 1 year ago

me too

b-mendoza commented 1 year ago

I can confirm the same is happening for me

srinivasjonnala commented 1 year ago

Same for me

b-mendoza commented 1 year ago

Hey @srinivasjonnala, @mbnaj & @whoisdon

It seems the fix is under this alpha version

After installing this version, it started to work!

srinivasjonnala commented 1 year ago

Hey @srinivasjonnala, @mbnaj & @whoisdon

It seems the fix is under this alpha version

After installing this version, it started to work!

Thank you @b-mendoza you save my day

whoisdon commented 1 year ago

image

yes thank you kkkkkk now I'm going to extend this module

itscherly commented 1 year ago

If I may know, to get this element, where do you inspect? I can't connect to several elements that exist in the issue or PR wweb

whoisdon commented 12 months ago

@renzhxr I don't understand your question, can you be more specific?

If possible, mention me to see the message

itscherly commented 12 months ago

@renzhxr I don't understand your question, can you be more specific?

If possible, mention me to see the message

I experienced an error like this when headless was false and I ran it on Ubuntu https://github.com/pedroslopez/whatsapp-web.js/issues/2555

whoisdon commented 12 months ago

In any case, hadless will necessarily be true in puppeteer, so much so that if you use it it purely returns a warning about it.