Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
ccmks opened this issue Feb 20, 2023 · 26 comments
Closed
1 task done

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

ccmks opened this issue Feb 20, 2023 · 26 comments
Labels
bug Something isn't working

Comments

@ccmks
Copy link

ccmks commented Feb 20, 2023

Is there an existing issue for this?

  • 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 ccmks added the bug Something isn't working label Feb 20, 2023
@CSFelix
Copy link

CSFelix commented Feb 20, 2023

Same issue here

@dannysantino
Copy link

dannysantino commented Feb 20, 2023

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.

@aangwie
Copy link

aangwie commented Feb 20, 2023

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

@fabiomello
Copy link

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

@ccmks
Copy link
Author

ccmks commented Feb 20, 2023 via email

@JeremiahChurch
Copy link

same as #2005?

@wilsinho8
Copy link

same as #2005?

Yes

@ccmks
Copy link
Author

ccmks commented Feb 21, 2023

How to fix the issue?

@massimorm
Copy link

also i have same problem on different sessions

@LaboratorySales
Copy link

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

@hcalldee
Copy link

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

@unish7
Copy link

unish7 commented Feb 25, 2023

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

@ccmks
Copy link
Author

ccmks commented Feb 25, 2023 via email

@massimorm
Copy link

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

@Olinari
Copy link

Olinari commented Mar 3, 2023

+1

@johnhoffmannsantos
Copy link

johnhoffmannsantos commented Mar 6, 2023

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

@Useems
Copy link

Useems commented Mar 28, 2023

Same

@ccmks
Copy link
Author

ccmks commented Apr 6, 2023

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?

@Useems
Copy link

Useems commented Apr 6, 2023

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.

@ccmks
Copy link
Author

ccmks commented Apr 6, 2023 via email

@charles-adedotun
Copy link

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

@brilyanilhamsadewo
Copy link

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

@JeremiahChurch
Copy link

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

@arielolin
Copy link

Yes please!

@andresrodriguezsantos44

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);
    });
}

}

@guy4261
Copy link

guy4261 commented Jun 13, 2023

@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.

@alechkos alechkos marked this as a duplicate of #2164 Dec 4, 2023
@alechkos alechkos closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests