whatsapp-web.js
whatsapp-web.js copied to clipboard
ππ session does not persist using LocalAuth id ππ
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I have been using "whatsapp-web.js" in my application for about 6 months, and yesterday the session persistence stopped working, I am using authStrategy: new LocalAuth({ clientId: user._id })
, and with this When I want to use the WhatsApp channel again, I can use it without having to scan the QR again, but every time that I want to use the channel and send messages, it is making me to scan the QR and this was not happening until yesterday
Expected behavior
for first time scan the QR once, and be able to continue using whatsapp without having to scan each time I use it
Steps to Reproduce the Bug or Issue
- configure the server in linux to work
- configure whatsapp web js with
authStrategy: new LocalAuth({ clientId: "some-client-id" })
- scan the QR and send a message
- reuse sending messages with the same "some-client-id"
Relevant Code
function authWhatsapp (user) => {
console.log("init authentication");
const client = await new Client({
authStrategy: new LocalAuth({ clientId: user._id }), // user = {_id: "1234abc", name: "juan"}
qrMaxRetries: 3,
authTimeoutMs: 60000,
puppeteer: {
executablePath: process.env.CHROME_EXECUTABLE_PATH, // CHROME_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
args: ["--no-sandbox", "--disable-setuid-sandbox"],
},
});
client.on("qr", async (qr) => {
console.log("scan qr");
console.log(qr);
});
client.on("ready", async () => {
console.log("Wapp web connected");
});
}
function sendWhatsapp (user) => {
console.log("try send messages");
client = await new Client({
authStrategy: new LocalAuth({ clientId: user._id }), // user = {_id: "1234abc", name: "juan"}
authTimeoutMs: 60000,
puppeteer: {
executablePath: process.env.CHROME_EXECUTABLE_PATH, // CHROME_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
args: ["--no-sandbox", "--disable-setuid-sandbox"],
},
});
client.on("ready", async () => { // this is never executed π«€
console.log("perfect, your are authenticated, Wapp web connected");
/*
code to send messages...
*/
});
client.on("qr", async (qr) => {
console.log("The whatsapp is asking for QR you are not authenticated");
console.log(qr);
});
}
for authWhatsapp function:
> init authentication
> scan qr
> [email protected]+29CIw=
> Wapp web connected
for sendWhatsapp function:
> try send messages
> The whatsapp is asking for QR you are not authenticated
> [email protected]=
Browser Type
Google Chrome
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Ubuntu 20
Phone OS: Android, iOS
whatsapp-web.js version [1.19.5]
WhatsApp Web version [2.2317.10]:
Node.js Version [v19.8.1]
Additional context
remember: this was not happening until yesterday, I already tried setting all the permissions to the .wwebjs_auth folder, and to all its content, but it's still the same, I also notice that in windows (no server -> my personal computer) with exactly the same configuration but using CHROME_EXECUTABLE_PATH=C:/Program Files/Google/Chrome /Application/chrome.exe
, it is working correctly, any idea why?
maybe the session files are not being saved correctly in the ".wwebjs_auth" folder, but I don't really know how to look at that part
Update: in other computer with Windows is happenig the same issue so is not the OS.
I am experiencing the same problem. I have been using it for a few weeks without a problem and since yesterday it has been disconnecting me often and it does not notify me why it happens. Anyone else with this error?
The whatsapp version that whatsapp-web.js mark like "working with" is = WhatsApp_Web 2.2306.7, and Now the current WhatsApp Web version is 2.2317.10. maybe something with session was changed
I am experiencing the same problem. I have been using it for a few weeks without a problem and since yesterday it has been disconnecting me often and it does not notify me why it happens. Anyone else with this error?
The whatsapp version that whatsapp-web.js mark like "working with" is = WhatsApp_Web 2.2306.7, and Now the current WhatsApp Web version is 2.2317.10. maybe something with session was changed
I am experiencing the same problem. I have been using it for a few weeks without a problem and since yesterday it has been disconnecting me often and it does not notify me why it happens. Anyone else with this error?
Pudiste encontar solucion??
At first I found a solution, for now it's working. In the package.json inside node_modules/whatsapp-web... change the version of puppeteer to 18.1.0
At first I found a solution, for now it's working. In the package.json inside node_modules/whatsapp-web... change the version of puppeteer to 18.1.0
Is weird because that works some times
same here
Same here
benjachiban
I tried it, didn't work
Same problem change the version of puppeteer to 18.1.0 dont work
@pedroslopez , some idea about this?
same here
same here :(
At first I found a solution, for now it's working. In the package.json inside node_modules/whatsapp-web... change the version of puppeteer to 18.1.0
It worked for me, update puppeteer to 20.3.0
At first I found a solution, for now it's working. In the package.json inside node_modules/whatsapp-web... change the version of puppeteer to 18.1.0
It worked for me, update puppeteer to 20.3.0
Please fulls steps. I need a npm install then?
My puppeteer is on version 20.3.0 but the error persists.
@pedroslopez Maybe your help?
up
UP, session persistence is super unconsistent.
same problem
I had the same problem with session in another library, it seems this problem is related to some thing that Whatsapp changed. Maybe it's a false impression I've tested different libraries.
Hi, I resolved it with permission chmod on both .wwebjs_auth and .wwebjs_cache directories
regards
Hi, I resolved it with permission chmod on both .wwebjs_auth and .wwebjs_cache directories
regards chmod 777 .wwebjs_cache
still ask to scan qr code
up again
still happening
every restart localauth not working , and send new QR, any solution to this?
every restart localauth not working , and send new QR, any solution to this?
Have you tried the solutions mentioned above? Try updating Puppeteer to version 20.3.0 in Node_modules/whatsapp-web.js/package.json and then run 'npm update'. This worked for me.
This is how i fix this issue:
1/ make sure .wwebjs_auth is created after login, otherwise likely your code problem 2/ puppeteer is update 3/ make sure .wwebjs_auth is chmod 777
why this is closed if actually not work?
the solution is to wait a couple minutes after the first qr code scan to let the session be "populated" properly
also as mentioned here the session is being saved in .wwebjs_auth
, so make sure that folder is created properly
I scan the qrcode, I get the qrcode, authentications is fineβ¦if after 2 hour I restart the server I need to rescan qrcode, so itβs not a problem related to βwait some minutesβ