whatsapp-web.js
whatsapp-web.js copied to clipboard
Disconnect event not triggered, when logging out
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
So when I have my wwjs running for long, I have seen that if it gets logget out automatically but the'disconnected'
is not triggered.
I tried logging out from my phone also, It still doesnt trigger the disconnected event.
Expected behavior
I am supposed to see the disconnected logs, i.e. console.error("Client was logged out", reason);
when disconnected.
Steps to Reproduce the Bug or Issue
Starting the client. And waiting for long enough for it to get disconnected or, forcing log out from the device.
Relevant Code
this._client = new Client({
puppeteer: {
headless: true,
executablePath: process.env.CHROME_BIN || "",
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--unhandled-rejections=strict",
],
},
authStrategy: new LocalAuth(),
qrMaxRetries: 10,
webVersionCache: {
type: "remote",
remotePath: `https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/${appConfig.WAWEB_VERSION}.html`,
},
});
this._client.on("change_state", async (state) => {
this._sessionStatus = state;
if (state === "CONNECTED") {
console.info("Client is connected!");
this._session = "successChat";
this._sessionStatus = "successChat";
}
});
this._client.on("ready", () => {
console.log("Client is ready!");
this._session = "successChat";
this._sessionStatus = "successChat";
});
this._client.on("disconnected", (reason) => {
console.error("Client was logged out", reason);
this.destroyClientInstance();
});
const resp = await this._client.initialize();
Browser Type
Google Chrome
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Amazon ami 2 phone: Samsung S22 plus whatsapp-web.js version: latest master from github with PR(https://github.com/pedroslopez/whatsapp-web.js/pull/2816) Node.js version: 18.12.1
Thanks in advance, LMK if I am missing something.
Additional context
No response