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

WhatsApp web have to re-scan QR code every around 10 days

Open ccmks opened this issue 2 years ago • 24 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

I am using Windows based, and keep experience constantly that I have re-create new session and re-scan QR code to get WhatsApp re-authenticate

Expected behavior

Shouldn't have to do this all time, expected to scan the QR code and forget about it

Steps to Reproduce the Bug or Issue

Just install like usual, then scan QR code, wait around 10 days and session will disappear from http://localhost:8000/send-message and I have to re-create new session again

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: Windows Phone OS: Android whatsapp-web.j version: I don't know how to find that

Additional context

No response

ccmks avatar Feb 20 '23 00:02 ccmks

Same issue here

CSFelix avatar Feb 20 '23 01:02 CSFelix

Yeah, I just realised that this seems to be the cause of this error I spent days trying to fix:

Evaluation failed: TypeError: Cannot read properties of undefined (reading 'canSend')

My session doesn't last up to ten days, though.

And now that I'm aware of the cause, I'm not so sure it's that much of an issue. I mean, don't you think it kind of poses a security risk to leave the session (from an unofficial library) running indefinitely? I could be wrong, though.

dannysantino avatar Feb 20 '23 07:02 dannysantino

same with me. every 10 days can't access and must be logged out first after that relogin again. I m don't use whatsapp business

aangwie avatar Feb 20 '23 09:02 aangwie

You have to open whatsapp on phone and interact every 9 days to doesnt disconnect.

fabiomello avatar Feb 20 '23 13:02 fabiomello

We use whatsapp on phone daily, so this is not the case.

On Mon, Feb 20, 2023, 9:10 PM Fábio Miguel Mello @.***> wrote:

You have to open whatsapp on phone and interact every 9 days to doesnt disconnect.

— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/2013#issuecomment-1437003747, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALYEL6RSUSHILKKKEDIXWOLWYNULNANCNFSM6AAAAAAVBIIKWI . You are receiving this because you authored the thread.Message ID: @.***>

ccmks avatar Feb 20 '23 13:02 ccmks

same as #2005?

JeremiahChurch avatar Feb 20 '23 15:02 JeremiahChurch

same as #2005?

Yes

wilsinho8 avatar Feb 20 '23 17:02 wilsinho8

How to fix the issue?

ccmks avatar Feb 21 '23 17:02 ccmks

also i have same problem on different sessions

massimorm avatar Feb 21 '23 18:02 massimorm

Sessions also fly off, customers are dissatisfied. I use LocalAuth, recently switched to RemoteAuth and regretted it, it generally works awfully. It happens that you start one account, and another one starts

LaboratorySales avatar Feb 21 '23 21:02 LaboratorySales

i also get the same problem always rescaned qr every cli killed

hcalldee avatar Feb 24 '23 03:02 hcalldee

The same thing happened to me and I changed the authentication method to RemoteAuth, the session remained open for exactly 30 days. The 4 instances with different sessions that I had open were closed on the same day. I have not found information on how to make it stay indefinitely

unish7 avatar Feb 25 '23 01:02 unish7

Where to change to RemoteAuth?

On Sat, Feb 25, 2023, 9:22 AM unish7 @.***> wrote:

The same thing happened to me and I changed the authentication method to RemoteAuth, the session remained open for exactly 30 days. The 4 instances with different sessions that I had open were closed on the same day. I have not found information on how to make it stay indefinitely

— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/2013#issuecomment-1444865014, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALYEL6VUJWRIFBFUPQXSJWTWZFNEVANCNFSM6AAAAAAVBIIKWI . You are receiving this because you authored the thread.Message ID: @.***>

ccmks avatar Feb 25 '23 11:02 ccmks

there are many users with the same problem. does anyone have a method to solve the problem? @pedroslopez

massimorm avatar Feb 26 '23 15:02 massimorm

+1

Olinari avatar Mar 03 '23 17:03 Olinari

Same Problem Here, my sessions only last 3 days and when it falls out they all fall out

johnhoffmannsantos avatar Mar 06 '23 21:03 johnhoffmannsantos

Same

Useems avatar Mar 28 '23 12:03 Useems

Now, that I have to rescan every several minutes now. It is more and more become annoying....

Any solution on this issue? I think this is a bug or something?

ccmks avatar Apr 06 '23 07:04 ccmks

Being someone with 20+ instances of whatsapp running on the same machine, I can pass on my experience:

  • Graceful shutdown, destroy all running instances before destroying the process.
  • Make constant backups of your instances, I usually do it when the process is being destroyed, but I haven't tested backups at intervals (maybe it's even better and safer).
  • Avoid using current RemoteAuth solution with mongodb, it's too unstable in my humble opinion. I thought it would improve this problem, but it actually made it A LOT worse.

Useems avatar Apr 06 '23 13:04 Useems

Hi where can I check for RemoteAuth settings? I want to see if mine is enabled or not

Message ID: @.*** com>

ccmks avatar Apr 06 '23 19:04 ccmks

Being someone with 20+ instances of whatsapp running on the same machine, I can pass on my experience:

  • Graceful shutdown, destroy all running instances before destroying the process.
  • Make constant backups of your instances, I usually do it when the process is being destroyed, but I haven't tested backups at intervals (maybe it's even better and safer).
  • Avoid using current RemoteAuth solution with mongodb, it's too unstable in my humble opinion. I thought it would improve this problem, but it actually made it A LOT worse.

What method are you using to authenticate your sessions please? If RemoteAuth, what DB are you using? Thanks

charles-adedotun avatar Apr 07 '23 12:04 charles-adedotun

Any suggestions for resolving this issue? For me, it barely lasts for two hours until I must rescan the QR code.

brilyanilhamsadewo avatar May 07 '23 08:05 brilyanilhamsadewo

Being someone with 20+ instances of whatsapp running on the same machine, I can pass on my experience:

  • Graceful shutdown, destroy all running instances before destroying the process.
  • Make constant backups of your instances, I usually do it when the process is being destroyed, but I haven't tested backups at intervals (maybe it's even better and safer).
  • Avoid using current RemoteAuth solution with mongodb, it's too unstable in my humble opinion. I thought it would improve this problem, but it actually made it A LOT worse.

@Useems could you share some examples for how you're implementing #1 & #2? That would be really helpful.

We had a similar experience with remote auth - seemed like it would help us but we also had reliability issues and for whatever reason (we didn't debug in depth) we had bounced sessions more often. Without remote auth we pretty reliably get 2 weeks before a re-auth

JeremiahChurch avatar May 07 '23 22:05 JeremiahChurch

Yes please!

arielolin avatar May 08 '23 04:05 arielolin

Esta es mi clase whatsappClient y no he tenido problemas. usando "whatsapp-web.js": "^1.21.0"

import { Service, Inject } from 'typedi'; import qrcode from 'qrcode-terminal'; import { Client, LocalAuth } from 'whatsapp-web.js'; import { ClientStatus } from './client-status'; import { handleMessage } from './messageHandler'; @Service() export class WhatsAppClient { client: Client; clientStatus: ClientStatus;

constructor(@Inject() clientStatus: ClientStatus) {
    this.client = new Client({
        authStrategy: new LocalAuth(),
    });
    this.clientStatus = clientStatus;
}

initialize() {
    console.log('Initializing whatsapp client...');
    this.client.initialize().then();
}

listenToMessages() {
    this.client.on('qr', (qr) => {
        qrcode.generate(qr, { small: true });
    });

    this.client.on('authenticated', () => {
        console.log('Client is authenticated!');
    });

    this.client.on('ready', () => {
        console.log('Client is ready!');
    });

    this.client.on('disconnected', (reason) => {
        console.log('Client is disconnected: ', reason);
        this.client.initialize().then();
    });

    this.client.on('message', async (msg) => {
        await handleMessage(msg, this.clientStatus);
    });

    process.on('unhandledRejection', (error) => {
        console.error('Unhandled Promise Rejection:', error);
    });
}

}

andresrodriguezsantos44 avatar May 30 '23 17:05 andresrodriguezsantos44

@Useems
> Graceful shutdown, destroy all running instances before destroying the process.

What's the proper way to gracefully shutdown? Client has bot logout and destroy, but I can't find any mention of the right way to gracefully shutdown.

guy4261 avatar Jun 13 '23 09:06 guy4261