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

statusFind of create method in loop #1980

Open
Divino67 opened this issue Dec 7, 2023 · 1 comment
Open

statusFind of create method in loop #1980

Divino67 opened this issue Dec 7, 2023 · 1 comment
Labels
bug Something isn't working needs triage

Comments

@Divino67
Copy link

Divino67 commented Dec 7, 2023

Description

Apparently it's for no reason, the cell phone is connected and the statusSession of the create() method statusFind is equal to 'inChat'. All of this works normally and it sends messages normally.

The statusFind is changed whenever there is a change in the device status. However, after some time, the method kind of goes into a loop and keeps returning the statusFind 'inChat' all the time, causing the device to disconnect.

I placed a console.log to identify the time when the statusFind function was called with the "new" status.

This is the method with console.log:

(statusSession, session) => {
console.log('statusSession --> ', statusSession, moment().tz(process.env.APP_TIMEZONE).format('DD/MM/YYYY HH:mm:ss'));

this.io.emit('status_connection', statusSession);
}

This is the console log:

DEBUG: 04/12/2023 18:49:22Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 18:49:22
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Connected

DEBUG: 04/12/2023 18:49:23Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 18:49:23
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Connected

DEBUG: 04/12/2023 19:02:34Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 19:02:34
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Connected

DEBUG: 04/12/2023 19:02:36Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 19:02:36
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Connected

DEBUG: 04/12/2023 20:16:08Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 20:16:08
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Emitting onInterfaceChange event (1 registered)
[clientName:client] Current state: MAIN (NORMAL)
[clientName:client] Emitting onStateChange event (1 registered)
[clientName:client] Connected

DEBUG: 04/12/2023 20:16:09Whatsapp.statusFind (/home/app/project/app/Bo/WppBo.js:96:25)
statusSession --> inChat 04/12/2023 20:16:09
[clientName:client] Emitting onAnyMessage event (1 registered)
[clientName:client] Emitting onAnyMessage event (1 registered)

Note that there is a pattern, but there is no warning of when this will occur, it simply starts to occur.
When this problem occurs and there is a reconnection attempt, I get the following error:

Error: WPP is not defined
at /home/r2-app/r2-whatsapp-api/node_modules/@wppconnect-team/wppconnect/dist/api/helpers/evaluate-and-return.js:107:31
at step (/home/r2-app/r2-whatsapp-api/node_modules/@wppconnect-team/wppconnect/dist/api/helpers/evaluate-and-return.js:49:23)
at Object.next (/home/r2-app/r2-whatsapp-api/node_modules/@wppconnect-team/wppconnect/dist/api/helpers/evaluate-and-return.js:30:53)
at fulfilled (/home/r2-app/r2-whatsapp-api/node_modules/@wppconnect-team/wppconnect/dist/api/helpers/evaluate-and-return.js:21:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
JS Stack: ReferenceError: WPP is not defined
at pptr:evaluate;%2Fhome%2Fr2-app%2Fr2-whatsapp-api%2Fnode_modules%2F%40wppconnect-team%2Fwppconnect%2Fdist%2Fapi%2Fhelpers%2Fevaluate-and-return.js%3A99%3A56:57:29
at pptr:evaluate;%2Fhome%2Fr2-app%2Fr2-whatsapp-api%2Fnode_modules%2F%40wppconnect-team%2Fwppconnect%2Fdist%2Fapi%2Fhelpers%2Fevaluate-and-return.js%3A99%3A56:58:28
at new Promise ()
at anonymous (pptr:evaluate;%2Fhome%2Fr2-app%2Fr2-whatsapp-api%2Fnode_modules%2F%40wppconnect-team%2Fwppconnect%2Fdist%2Fapi%2Fhelpers%2Fevaluate-and-return.js%3A99%3A56:54:14)
Function: function () {
return WPP.whatsapp.Socket.state;
}

Environment

  • WPPConnect version(s): 1.28.3
  • WA-JS version(s): 2.28.0
  • Browser: Chrome 119.0.6045.199
  • OS: Linux Ubuntu 22.04
  • Node version: Node 16.14.2
  • WhatsApp version: 2.2347.56

Steps to Reproduce

1 - Start the connect app
2 - Scan the QR Code and connect the device
3 - Wait and monitor the logs

@Divino67 Divino67 added bug Something isn't working needs triage labels Dec 7, 2023
@icleitoncosta
Copy link
Contributor

Hello, please update your project and NodeJs to v18+ and test again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants