whatsapp-web.js
whatsapp-web.js copied to clipboard
Client.getState() returning with state connected but in reality it's not connected. Session Falling.
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I have an interval function in my robot that checks the connection status every 10 seconds using the setInterval method. The code is as follows:
checkInterval = setInterval(async () => {
const state = await Robot.client.getState();
console.log('Status do Robô:', state)
if(state != WAState.CONNECTED && state != WAState.OPENING && state != WAState.PAIRING){
await Robot.fallDown('Status do Robô: ' + state);
}
}, 10 * 1000);
The code appears to be working fine as it consistently shows that the robot is connected and able to send messages. However, I have noticed that sometimes the robot loses its connection with the WhatsApp server, which I can see from the lack of ACK responses. Even though the robot continues to display a connected status, it is actually disconnected and unable to really send or receive messages.
When this happens, I have to restart the robot, and It asks to scan the QR Code again to reestablish the connection. It seems that something happens to the session during these intermittent connection drops.
Expected behavior
It should keep the connection opened, or client.getState() should display the right state.
Steps to Reproduce the Bug or Issue
Just stay connected for a while
Relevant Code
No response
Browser Type
Google Chrome
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
Ubuntu 22.04 Node.js: 16.16 whatsapp-web.js: ^1.19.5 Phone: Android WhatsApp: 2.2314.7
Additional context
No response
Same here
I don't lose the session but if that happens to me what do you explain, any solution?
Exact same thing here, also change_state neither disconnected events are never triggered. I saw that sometimes the change state event is triggered after hours of disconnection, but by checking the state changes they indicate a lost connection for only a couple of seconds, despite the connection to send messages or get messages info is not working, neither before or after those state_change events... The only thing that makes everything comes back to normal is to reset the whole application, and everytime that this happen I need to rescan the qr code again...
any solution for this issue?
@samuelfaj Is still relevant?
This is happening to us too, is there any way to solve this?It's very important for us! Thanks!
We are dealing with this issue as well!
getstate is definitely broken
Any solution here?
Anywhere find any solution?