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
15.34k stars 3.66k forks source link

how to recover a hanged browser without rescanning again the whatsapp #1792

Closed Tina4545 closed 1 year ago

Tina4545 commented 1 year ago

Is there an existing issue for this?

Describe the bug

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..

Expected behavior

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..

Steps to Reproduce the Bug or Issue

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..

Relevant Code

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

Additional context

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

lfdelphino commented 1 year ago

What OS are you using this lib on? I've never had anything similar happening before.

Since you are aware that the screen becomes white, I'm assuming you are not running Chrome headless. Have you ever tried running headless? If you observe that the headless browser takes longer to hang or doesn't even freeze, the server is likely overloaded.

Tina4545 commented 1 year ago

Im using windows os... How do i set up to use headless chrome?

On Sat, Nov 12, 2022, 22:38 Luiz Delphino @.***> wrote:

What OS are you using this lib on? I've never had anything similar happening before.

Since you are aware that the screen becomes white, I'm assuming you are not running Chrome headless. Have you ever tried running headless? If you observe that the headless browser takes longer to hang or doesn't even freeze, the server is likely overloaded.

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

lfdelphino commented 1 year ago

Delete the current session folder (.wwebjs_auth by default). Install and use qrcode-terminal so we can render the QR code:

$ npm i qrcode-terminal

And now we'll modify our code to use this new module:

const qrcode = require('qrcode-terminal');

const { Client } = require('whatsapp-web.js');
const client = new Client({
    authStrategy: new LocalAuth(
        clientId = "my_wpp"
    ),
    qrMaxRetries: 5,
    puppeteer: { 
        headless: true,
        channel: 'chrome',
        args: ['--no-sandbox', '--max_old_space_size']
    }
});

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

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

client.initialize();

There we go! You should now see something like this after running the file:

After scanning this QR code, the client should be authorized and you should see a Client is ready! message being printed out.

Tina4545 commented 1 year ago

I have started using a headless browser now... so does it mean that it will never hang???

amosayomide05 commented 1 year ago

Just restart

PurpShell commented 1 year ago

I want to join on the bandwagon

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

a browser mostly hangs and does not load chats and remains frozen on a blank white screen... I know that it's not possible to avoid this but is there any way of deleting something in the session files so that we don't have to force the logout on the phone and re- scan again the QR code..re-scan

stop this and do something that will allow us to help you and dig deeper, will ya? Those fields aren't for spam and our time as a community isn't to be spent dealing with this. Closing