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
14.62k stars 3.48k forks source link

client ready is not working. whatsapp not detecting web login ? #2493

Closed laroussev closed 10 months ago

laroussev commented 10 months ago

Is there an existing issue for this?

Describe the bug

Whatsapp web js does not read client ready for the last 3 days, although I read qr. But can you help me log in?

Expected behavior

client ready is not working. whatsapp not detecting web login ?

Steps to Reproduce the Bug or Issue

client ready is not working. whatsapp not detecting web login ?

Relevant Code

const { Client } = require("whatsapp-web.js"); const qrcode = require("qrcode-terminal"); const logData = require("./logger"); const express = require("express"); const bodyParser = require("body-parser"); const qs = require("qs"); const axios = require("axios");

const app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json());

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

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

client.on("ready", () => { console.log("WhatsApp Web bağlantısı başarılı. (/sendMessage)");

// POST isteklerini dinlemek için sunucuyu başlatın app.listen(3000, () => { console.log("Sunucu çalışıyor. POST isteklerini bekliyor..."); }); });

client.on("message", (message) => { if (message.from.endsWith("@c.us")) { const postData = { phoneNumber: message.from, message: message.body }; axios .post("http://localhost/rabbot/chatMessage.php", qs.stringify(postData), { headers: { "Content-Type": "application/x-www-form-urlencoded", }, }) .then((response) => { logData(postData.phoneNumber, postData.message, "g"); console.log("Sunucu yanıtı:", response.data); }) .catch((error) => { console.error("Mesaj gönderilirken bir hata oluştu:", error); }); } }); app.post("/rabbot/sendMessage", (req, res) => { const key = req.body.key; const phoneNumber = req.body.phoneNumber; const message = req.body.message; if (!phoneNumber || !message) { console.log(Geçersiz istek.: ${phoneNumber} | ${message}); return res.status(400).json({ error: "Geçersiz istek." }); } client .sendMessage(phoneNumber, message) .then(() => { logData(phoneNumber, message, "c"); return res.status(200).json({ success: true }); }) .catch((error) => { console.error("Mesaj gönderilirken bir hata oluştu:", error); return res .status(500) .json({ error: "Mesaj gönderilirken bir hata oluştu." }); }); });

// WhatsApp Web'e bağlanmak için oturum açın client.initialize();

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

windows 10

Additional context

No response

oriyadid commented 10 months ago

Seems similar to #2490, #2487, #2480. I also encountered that issue (note that it was a few weeks ago), and updating the version to 1.22.2-alpha0 solved it for me personally.

edit: #2485 seems more relevant, but hasn't been merged yet, you might want to use that fork ("whatsapp-web.js": "brunox64/whatsapp-web.js#patch-1" in your package.json for @brunox64 's fix) for the moment. (you can also use #commit-id if you prefer)

oriyadid commented 10 months ago

I also ran into this now when restarting my client, and using that fork fixed it for me, so it's worth a try.