whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

lost authentication after restart

Open Julzk opened this issue 1 year ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

when I restart my node program, I very often (80%) lose authentication. I use "LocalAuth" and create a backup of the "dataPath" every 30 min. If a QR code scan is requested after the restart, I restore a backup, but this only works 5% of the time. I use docker and already have the "dataPath" stored inside the container or outside, no difference.

here is a screenshot after the restart https://i.imgur.com/dDTNvEt.png

Is there a better way to log what's happening?

GOOGLE-VM docker "node:16" node runs with pm2

Expected behavior

a connected WhatsAppWeb after restarting the node program

Steps to Reproduce the Bug or Issue

  1. docker node:16
  2. puppeteer 19.7.5
  3. whatsapp-web.js 1.19.5
  4. conntect via LocalAuth
  5. restart the node-application

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Linux Docker node:16 Phone: Android or iPhone (i have multiple WhatsApp Accounts, its happen on both devices) whatsapp-web.js: 1.19.5 WhatsApp Web version: 2.2316.6 nodejs: 16

Additional context

No response

Julzk avatar Apr 15 '23 12:04 Julzk

console log:

Another connection wants to delete database 'wawc'. Closing db now to resume the delete request.

Julzk avatar Apr 16 '23 12:04 Julzk

我也是

huangpd avatar Apr 17 '23 07:04 huangpd

Probably as you are using docker and on every restart your data folder may gets deleted. You mentioned you take backups every 30min. But that seems not a good choice. As contents of session data files may change every few minutes. And if main files or tokens changes inside data folder. And if u are dumping old session data files back, most of the times it may simply log you out, as your session files mismatch.

So try to use data folder from outside docker and make it a persistent storage folder which do not overwrite on docker restart.

crazytweeks avatar Apr 18 '23 15:04 crazytweeks

same here, after use LocalAuth correctly, If I need to recover the session to send more messages, it starts generating the QR codes again (this didn't happen before) and the "ready" event is not emitted

andresmv94 avatar Apr 20 '23 19:04 andresmv94

I really tried a lot, mounted volume, internal volume, delete meta-data, but what worked for me now is: "chmod 777 -R /whats-app-session-folder" (before initial client)

Julzk avatar Apr 22 '23 13:04 Julzk

I really tried a lot, mounted volume, internal volume, delete meta-data, but what worked for me now is: "chmod 777 -R /whats-app-session-folder" (before initial client)

tried it didn't work :(

mahmouds12 avatar May 05 '23 23:05 mahmouds12

Same happen to me, running this on Windows environment

ccmks avatar May 15 '23 01:05 ccmks

Hello, Having this same problem with docker. I'm using remote client to store de data with a mongoDB in the cloud

const client = new Client({
    authStrategy: new RemoteAuth({
      store: store,
      backupSyncIntervalMs: 300000,
      clientId: sessionName,
      dataPath: process.env.BOT_DATAPATH ? process.env.BOT_DATAPATH : './data/',
    }),
    restartOnAuthFail: true,
    puppeteer: {
      headless: true,
      args: [
        '--no-sandbox',
        // other node args
      ],
    },
  });

it works when I switch between laptops or pc locally but not with docker, it even works when I save the session via docker and then open it local but it doesn't restore authentication in docker for me, any idea of how to fix it ?

kaelabbott avatar Jul 04 '23 17:07 kaelabbott

What is your CPU and RAM usege?

shirser121 avatar Aug 04 '23 15:08 shirser121

@Julzk Is still relevant?

alechkos avatar Dec 04 '23 00:12 alechkos

no i solved it by use 2 cpus and 8gb ram in google cloud.

Julzk avatar Dec 04 '23 09:12 Julzk