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.53k stars 3.46k forks source link

LocalAuth is not saving the connection #2561

Closed whoisdon closed 7 months ago

whoisdon commented 9 months ago

Is there an existing issue for this?

Describe the bug

Even configuring LocalAuth() on the client it does not save my session, before it saved normally without any errors. Now it doesn't work, every time I restart the application I need to connect again.

Expected behavior

Save the session

Steps to Reproduce the Bug or Issue

My options:

const options = {
        authStrategy: new WABot.LocalAuth({ dataPath: `${process.cwd()}/src/Utils/.cache/.season` }),
        puppeteer: {
            executablePath,
            args: ['--no-sandbox']
        }
};

Relevant Code

import WABot from 'whatsapp-web.js';
import { glob } from "glob";
import { promisify } from "util";
const globPromise = promisify(glob);

const getChromePath = async () => {
    const chromeExecutablePath = await globPromise(`${process.cwd()}/chrome/*/*/chrome`);
    return chromeExecutablePath;
}

const createOptions = async () => {
    const executablePath = await getChromePath();

    const options = {
        authStrategy: new WABot.LocalAuth({ dataPath: `${process.cwd()}/src/Utils/.cache/.season` }),
        puppeteer: {
            executablePath,
            args: ['--no-sandbox']
        }
    };

    return options;
}

export default createOptions;

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

I am using the whatsapp-web.js v1.22.2-alpha.1 I am running the code on Node.js Verion v20.6.1. OS: Ubuntu OS CellPhone: Android

Additional context

image

SHIKHER09 commented 9 months ago

can I do this ??

whoisdon commented 9 months ago

can I do this ??

?????

donrep-daniil-shushpanov commented 7 months ago

?????

alechkos commented 7 months ago

Just checked the functionality:

const client = new Client({
    authStrategy: new LocalAuth(dataPath: './new_path'}),
    restartOnAuthFail: true,
    puppeteer: {
        headless: true,
        args: args,
        ...
    }
});

The session was stored in new_path successfully The issue is likely in your code not in the library