devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
878 stars 273 forks source link

Stuck on SCAN_QR_CODE #182

Closed gr8tushar closed 1 year ago

gr8tushar commented 1 year ago

Hi, When I create a session, I get the status in the response as STARTING. However, after sometime I get "SCAN_QR_CODE". After getting the screenshot and scanning the same, the status is stuck at SCAN_QR_CODE. It never passes that to reach WORKING. My server is up since 3 days. It was working a day before. If there any limitation to that ?

Thanks, Tushar

gr8tushar commented 1 year ago

Hi, Just to add some steps, which might add more context to the probelm.

I tried the following but still it is not working:

  1. Destroyed the docker instance, removed the image and ran the docker-compose up command.
  2. Setup a new server.

It is still not working.

Thanks.

allburov commented 1 year ago

HI!

  1. Could you try to remove .sessions folder if you're using Plus version? Is it Core or Plus btw?
  2. Which version do you use? you can find it by requesting GET /api/version/ If it's not the latest try to docker pull
  3. If it doesn't help - could you run a new container, run session, scan QR and provide docker logs for that so we can see if anything happened there
allburov commented 1 year ago
  1. Try to change an engine to NOWEB one, it sometimes work more stable! https://waha.devlike.pro/docs/how-to/engines/#noweb
gr8tushar commented 1 year ago

@allburov Here, you go:

  1. Core as of now
  2. { "version": "2023.8.10", "tier": "CORE", "browser": "/usr/bin/chromium" }
  3. I tried running on Linux Server (Ubuntu 22.04) - 2 different servers, newly deployed. Windows Desktop (docker)

`docker run -it --rm -p 3000:3000/tcp --name whatsapp-http-api devlikeapro/whatsapp-http-api yarn run v1.22.19 $ node --unhandled-rejections=none dist/main WAHA (WhatsApp HTTP API) - Running CORE version... [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [NestFactory] Starting Nest application... [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [InstanceLoader] PassportModule dependencies initialized +15ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [InstanceLoader] ServeStaticModule dependencies initialized +2ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [InstanceLoader] AppModuleCore dependencies initialized +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] SessionsController {/api/sessions}: +64ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sessions/start, POST} route +2ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sessions/stop, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sessions/logout, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sessions, GET} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] ChattingController {/api}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/checkNumberStatus, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendContactVcard, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendText, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendText, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendTextButtons, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendLocation, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendLinkPreview, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendImage, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendFile, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendVoice, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/reply, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/sendSeen, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/startTyping, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/stopTyping, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/reaction, PUT} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/messages, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] ChatsController {/api/:session/chats}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/chats, GET} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/chats/:chatId, DELETE} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/chats/:chatId/messages, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/chats/:chatId/messages, DELETE} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] StatusController {/api/:session/status}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/status/text, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/status/image, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/status/voice, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/status/video, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] ContactsController {/api/contacts}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts, GET} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/all, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/check-exists, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/about, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/profile-picture, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/block, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/contacts/unblock, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] GroupsController {/api/:session/groups}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/settings/security/info-admin-only, PUT} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id, DELETE} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/leave, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/description, PUT} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/subject, PUT} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/invite-code, GET} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/invite-code/revoke, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/participants, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/participants/add, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/participants/remove, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/admin/promote, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/groups/:id/admin/demote, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] PresenceController {/api/:session/presence}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/presence, POST} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/presence, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/presence/:chatId, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/:session/presence/:chatId/subscribe, POST} route +1ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] ScreenshotController {/api}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/screenshot, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RoutesResolver] VersionController {/api/version}: +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [RouterExplorer] Mapped {/api/version, GET} route +0ms [Nest] 34 - 08/23/2023, 6:27:49 AM LOG [NestApplication] Nest application successfully started +2ms WhatsApp HTTP API is running on: http://[::1]:3000 [Nest] 34 - 08/23/2023, 6:28:16 AM LOG [SessionManager] 'default' - starting session... [Nest] 34 - 08/23/2023, 6:28:16 AM LOG [Webhook - default] Configuring webhooks for https://httpbin.org/post... [Nest] 34 - 08/23/2023, 6:28:16 AM LOG [Webhook - default] Event 'message' is enabled for url: https://httpbin.org/post [Nest] 34 - 08/23/2023, 6:28:16 AM LOG [Webhook - default] Webhooks were configured for https://httpbin.org/post.

[QR IMAGE] `

Adding few more details, just for reference: http://localhost:3000/api/sessions?all=false [ { "name": "default", "status": "SCAN_QR_CODE", "config": { "proxy": null, "webhooks": [ { "url": "https://httpbin.org/post", "events": [ "message" ], "hmac": null, "retries": null, "customHeaders": null } ] } } ]

I am getting correct screenshots - they show the actual screen of my WhatsApp instance.

If I try to send a message, which the status is still "SCAN_QR_CODE", I get the following error: { "statusCode": 500, "timestamp": "2023-08-23T06:30:52.148Z", "exception": { "stack": "Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'WidFactory')\n at __puppeteer_evaluation_script__:2:42\n at ExecutionContext._evaluateInternal (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async ExecutionContext.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)\n at async Client.sendMessage (/app/node_modules/whatsapp-web.js/src/Client.js:869:28)\n at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28\n at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17", "message": "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'WidFactory')\n at __puppeteer_evaluation_script__:2:42", "name": "Error" }, "request": { "path": "/api/sendText?phone=[abcdefchi]&text=Hi%2C%20A%20sample%20msg%20from%20localhost%20docker&session=default", "method": "GET", "body": {}, "query": { "phone": "918076193798", "text": "Hi, A sample msg from localhost docker", "session": "default" } }, "version": { "version": "2023.8.10", "tier": "CORE", "browser": "/usr/bin/chromium" } }

Facing the same issue.

gr8tushar commented 1 year ago

@allburov How do you get a QR code in NOWEB. When I try to get the screenshot, it shows me an error saying that screenshot cannot be taken. In create event, I didn't get anything as such.

allburov commented 1 year ago

Hi! Yes, NOWEB doesn't run chrome under the hood, so there'll be no screenshot :) Weird tho, it should give you QR on screenshot endpoint anyway You can use GET /api/{session}/auth/qr endpoint for that, it's available in the latest version 2023.8.19. Could you also try default engine in the updated verison, may be the update'll help you

gr8tushar commented 1 year ago

Hi, Thanks for the answer. I tried the latest version, but that still doesn't work. I checked the logs in the Docker. After scanning the code, the log stops displaying the QR code (which is the behavior of WEBJS) but still the status of the session is "SCAN_QR_CODE". Looks like the ready event is not fired.

allburov commented 1 year ago

So weird, just tested it one more time with Core and it works, no delays, became WORKING pretty fast. I see there's some mentions of the same issue in the engine about that too https://github.com/pedroslopez/whatsapp-web.js/issues

Let's give it one more change - I've updated WEBJS engine to the latest one and published 2023.8.23 - could you pull new image, restart containers and try again?

~~If it doesn't help - let's try using pairing code instead of QR https://waha.devlike.pro/docs/how-to/sessions/#get-pairing-code The process is simple:~~ Sorry, pairing doesn't work on WEBJS, forgot about that :(

gr8tushar commented 1 year ago

Hi, It's still not working :( .

Version: { "version": "2023.8.23", "tier": "CORE", "browser": "/usr/bin/chromium" }

Session List: [ { "name": "default", "status": "SCAN_QR_CODE", "config": { "proxy": null, "webhooks": [ { "url": "https://{{MyActualDomain}}/waapi", "events": [ "message.ack" ], "hmac": null, "retries": { "delaySeconds": 2, "attempts": 2 }, "customHeaders": null } ] } } ]

The webhook URL is live and working.

Do let me know in case you need any other info.

gr8tushar commented 1 year ago

@allburov - https://github.com/pedroslopez/whatsapp-web.js/issues/2422#issuecomment-1687313278 Looks like they are changing the UI or some elements.

allburov commented 1 year ago

Hi! There's a republished 2023.8.23 with the fix available, try this one and let us know if it helped!

gr8tushar commented 1 year ago

@allburov It's working!!!! :))

tristan-thar commented 1 year ago

Hi @allburov, can you also update with this fix the arm PLUS version please? The latest version there is 2023.8.13 where this issue is still present. Thanks 😄

allburov commented 1 year ago

@heureka-dev oh, sorry for that :( I've pushed the update image few minutes ago, please pull it now

We must automate it so all images released at once... Created a task for that https://github.com/devlikeapro/whatsapp-http-api/issues/186

tristan-thar commented 1 year ago

Thanks a lot for the quick response @allburov. Works perfect now 😄

gr8tushar commented 1 year ago

Hi @allburov - Now I am using the plus version, but I have started facing the same issue again. I am using the following version: { "version": "2023.8.23", "tier": "PLUS", "browser": "/usr/bin/chromium" }

@heureka-dev Did the latest version work for you ?

@allburov All my sessions are in "STARTING" mode. I restarted the docker as well, but nothing happenned.

I was checking the logs and found this. Could be helpful in debugging. whatsapp-http-api-plus | (node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 12 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit whatsapp-http-api-plus | (Usenode --trace-warnings ...to show where the warning was created) whatsapp-http-api-plus | (node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 12 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit whatsapp-http-api-plus | (node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 12 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit whatsapp-http-api-plus | (node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 12 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit

Thanks, Tushar

allburov commented 1 year ago

Hi! So the issue is not the same, right? The status is different one (not qr scan) and the message too. Could you create a new issue please so we have a recording for that and won't lost communication here. Looking at that!

gr8tushar commented 1 year ago

@allburov My bad... Didn't realize that this time it is stuck with STARTING... I'll create a new one...