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.18k stars 3.62k forks source link

Persistent Session Troubles: wahtsapp-web.js Disconnects After 2-3 days #3224

Closed dowoh077 closed 2 months ago

dowoh077 commented 2 months ago

Is there an existing issue for this?

Describe the bug

whatsapp disconnect after 2 / 3 days

Expected behavior

The whatspp web js session should remain active and connected without requiring a QR code re-scan for an extended period, ideally beyond 2-3 days, ensuring seamless and uninterrupted usage.

Steps to Reproduce the Bug or Issue

1.) Set up wa web js and initialize the connection. 2.) Scan the QR code to link your whatsapp account. 3.) Ensure the connection is established and the session is active. 4.) Allow the session to remain active without manually disconnecting. 5.) Observe that after 2-3 days, the session disconnects automatically and requires a new QR code scan to reconnect.

Relevant Code

function createClient(phoneNumber, id) { if (!clients[phoneNumber]) { const sessionPath = path.join(__dirname, .wwebjs_auth); const client = new Client({ authStrategy: new LocalAuth({ clientId: phoneNumber, dataPath: sessionPath }), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-gpu', ],

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS ; Linux Phone : Android whatsapp-web.js version: Lates or webpack-exodus Node.js Version: 22.x

Additional context

Hey everyone,

How can I keep my login session active?

I mean, how do I make sure my WhatsApp stays connected with WhatsApp Web JS for more than just a few days?

I've checked out the issues on GitHub but can't find a solution.

What's happening is, after I scan the QR code, it automatically disconnects after 2 or 3 days.

What's up with that?

Is there a way to keep the connected device active for a longer time?