Whatsapp-web.js: client disconnected internet connection

Created on 8 Nov 2020  Â·  6Comments  Â·  Source: pedroslopez/whatsapp-web.js

[08/11/2020 11: 40: 43.770] Internet Device Client Connected
[08/11/2020 11: 45: 43.770] [LOG] Starting
[08/11/2020 11: 46: 04.179] [LOG] Received Authenticated Session
[08/11/2020 11: 46: 04.265] [LOG] WhatsApp Web v 2.2045.15
[08/11/2020 11: 46: 04.266] [LOG] WWebJS v ​​1.11.0
[08/11/2020 11: 46: 04.270] [LOG] WhatsApp CONNECTED
[08/11/2020 11: 46: 04,837] [LOG] WhatsApp Web {status: 200}
[08/11/2020 11: 46: 04.845] [LOG] Whatsapp Ready
[08/11/2020 11: 50: 04.845] Internet Device Client is Disconnected

Console + Chromium = no response
client.on ('disconnected', async (disconnected) => does not work

1

when Chromium is reloading manually
2

bug

All 6 comments

you can listen to 'change_state' event.
check 'Contants.js' file to get more info about the states.

I have the same issue

you can listen to 'change_state' event.
check 'Contants.js' file to get more info about the states.

already tried using

client.on ('change_state', async (change_state) => {
console.log ('WhatsApp: Device', change_state);
});

but still when the device connects and disconnects, the browser remains silent

riagie, in my experience, this has to do with the way whatsapp handle the socket connection with the phone.
the event you are looking for is 'TIMEOUT'.
it will trigger the event at some time, this time is a magic number handled by whatsapp itself.
i've found a way to force this event when sending a message to a chat (with the phone disconnected), and almost certain it will trigger 'TIMEOUT' on change_state.
after the reconnection, the 'CONNECTED' change_state is normally given faster, but i didn't really test this part too much.

TL'DR > probably, this is related with the way whatsapp itself handle the events.

sorry if i'm not helping much, this is the way i handle phone disconnection in my application and it's working just fine.

the part where the browser gets stuck trying to reconnect to the phone after reload, i dont think there's a easy way to detect this, because no connection was made, so, no events fired.
i just use the shipped solution of 45s timeout and reset the session to re-read the qrcode.
anyhow, wouldn't be too hard to implement a selector query to detect this 'trying reach the phone' page if you're willing to.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franciscol99 picture franciscol99  Â·  3Comments

therevolt picture therevolt  Â·  4Comments

makanSukros picture makanSukros  Â·  9Comments

tarikhagustia picture tarikhagustia  Â·  10Comments

ngekoding picture ngekoding  Â·  5Comments