whatsapp-web.js: session not load correctly anymore session -LocalAuth

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have been utilizing the “whatsapp-web.js” library in my application for approximately six months. However, yesterday I encountered an issue where the session persistence feature stopped functioning correctly. In my application, I employ the LocalAuth authentication strategy with clientId set to user._id. Normally, after scanning the QR code once, I can use the WhatsApp channel without the need to rescan the QR code. However, as of yesterday, I am required to scan the QR code every time I want to use the channel and send messages, which was not the case previously.

Expected behavior

Scan the QR code for the first time, and thereafter, enjoy uninterrupted usage of WhatsApp without the need to scan it again each time I access the application.

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

const whatsAppClient = new Client({
    authStrategy: new LocalAuth({
      clientId: clientId
    }),
    puppeteer: { headless },
    args: [
      "--no-sandbox",
      "--disable-setuid-sandbox",
      "--disable-extensions",
      '--disable-gpu',
      "--disable-accelerated-2d-canvas",
      "--no-first-run",
      "--no-zygote",
      "--disable-dev-shm-usage"
    ]
  });

  whatsAppClient.on('authenticated', data => {
    console.error(clientId + ' authenticated');
  });

  whatsAppClient.on('auth_failure', data => {
    console.log('auth_failure');
  });

  whatsAppClient.on('disconnected', (data) => {
    console.error(clientId + 'disconnected');
  });

  whatsAppClient.on('ready', async () => {
    console.log('ready ', clientId);
  });

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows Server 2022 Phone OS: IOS whatsapp-web.js version: 1.20.0 WhatsApp Web version [2.2317.10]: Node.js Version v14.17.3

Additional context

the session .wwebjs_auth file created correctly. After the first scanning it works. If the client close and start again its says please scan QR. The session file is still there…

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17

Most upvoted comments

Hi, what has really worked for me in these cases is to scan the qr code for the first time and wait at least 2 minutes without closing the program execution, after those 2 minutes you can close it and in theory the next time you log in you should not be asked to scan the qr code again if you are using the local auth as authentication strategy.

Hey! Your tip was really good. I did as you said here and it worked perfectly. Thank you so much for the advice!

I am facing a similar but slightly different issue. Apart from the problem with the selector, it seems that sometimes the LocalAuth stored is not used, and that makes the process to stuck waiting for the app to start. I made some screenshots and I see that whatsapp is asking me to scan the QR code, but it is not generating any QR code, hence the QR is not even being asked to scan. Here you can see the screenshot: image

I’m on MACOS