whatsapp-web.js: 🐛🐛 session does not persist using LocalAuth id 🐛🐛
Is there an existing issue for this?
- 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
> 2@Zy5JBs9MeMX0GBeDlNd1....RUI9lbeATZGDNBtx52+29CIw=
> Wapp web connected
for sendWhatsapp function:
> try send messages
> The whatsapp is asking for QR you are not authenticated
> 2@TYQbrQCmYVbCB0KG...dEy8edXIPh32AiME0=
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.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 60 (1 by maintainers)
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?
OK, I’ve managed to resolve the issue:
TL;DR Set the
webVersionto2.2306.7NestJS provider
Terminal Screenshot
It worked for me, update puppeteer to 20.3.0
Happy to hear 🥳
For future documentation - list here the versions you’re on please 🙏
@eduardotorresdev BTW, let the connection to establish for a minute or two…
You’ll see on your WhatsApp client over the device that your chats are in sync. Keep it that way for a bit, then test the restart.
+1
same for me. the library appears to have problems with multiple projects.
I have two projects:
when the client init is in the library project it cant restore the session, even if i directly specify it.
up again
up
Is weird because that works some times
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