Closed patricknicolosi closed 1 year ago
are you getting this on Web ? have you tried multiple times and getting this issue every time ?
I'm getting this on web https://rohitsangwan01.github.io/whatsapp_bot_flutter every time
@patricknicolosi can you try to connect with local puppeteer instance like this
Suddenly I get this exact same exception in Headlesss mode. With headless = false it works fine. I am not on Web, I am running it on MacOS. I tried to delete and clean everything (including local Chromium and data folder) - does not help. I also tried to use Puppeteer 3.1.1 instead of 3.1.0 - same.
What I get:
Exception has occurred.
WhatsappException ([ WhatsappException type : WhatsappExceptionType.failedToConnect , message : Failed to initialize WPP ])
@arytbk in Macos are you trying to connect with a url ( like web ) by running puppeteer separately , or running with normal connect method ?
Normal connection method…On 28 Jun 2023, at 11:28, Rohit Sangwan @.***> wrote: @arytbk in Macos are you trying to connect with a url ( like web ) by running puppeteer separately , or running with normal connect method ?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
I am using the normal Connect method
working fine for me , i just tried running the example app as it is , and its working fine in macos can you check with example app ?
@patricknicolosi seems like this issue is only with Browserless, i tried the Docker image of Browserless and its working fine, probably they changed something in their live version , javascript is not injecting into it
The example app does not work on my (platform:macOS, arch:arm64) MacOS. It crashes after closing the QR Code dialog as shown in this screenshot:
My app worked fine in headless mode but suddenly today I get this "Failed to initialize WPP" exception. Here is a screenshot to show exactly when that happens:
@arytbk try to clean the session directory and try again , sometimes session directory created in headless mode cause issue in non headless mode or vice versa or for testing , try without session directory
Ok I have more details. I removed the session directory and I launched my app. It asked me for the QR code and everything was fine. Then I closed Chromium (using the browser callback I get from connect) and quit my app. When I launch it again I get the exact same error. I'll try without closing Chromium but with my initial tests it created other issues...
If I don't close Chromium before quitting my app, next time I try to launch it and connect, I get an exception "Login Failed" after a long time in the state "ConnectionEvent.waitingForQrScan" (although WhatsApp was already properly connected the last time).
So maybe I am just missing the proper way to quit my app and leave Chromium etc in a clean state?
@arytbk there is some bug with the headless mode switch and session directory
session directory for now only works with headlessMode: false
if we use session directory in headless mode then getting some issues when we try to run next time
also if session directory created in headless mode , that will not work with non headless mode either
so yeah these things are yet to debug, these issues are related to puppeteer
I see! So currently the only way to maintain a session directory (to avoid having to reconnect WhatsApp with QR code at every launch of the app) is to use headless = false... Now I'll try to find a way to hide the Chromium app...
@arytbk well yes atleast for now
I found a workaround for now, by forcing Puppeteer version to 3.1.0 ("puppeteer: 3.1.0"). Now it works again in headless mode with a session directory to keep WhatsApp logged-in between launches of my app!
@arytbk i think the issue is , when we run puppeteer in headless mode, and stop our program, that headless browser keep running in background ( check in Activity monitor ), and next time we try to run again it causes an issue because that cache is still connected to that old instance , Try to manually close that headless browser instance running in background, and run program again to see if its working fine now, if yes then its puppeteer dart issue
I was already closing the hidden Chromium browser (I got the browser instance from the callback in connect, then before quitting the app I user browser.close()
if we close the browser , then it should work fine, atleast in my testing
I was already closing the hidden Chromium browser (I got the browser instance from the callback in connect, then before quitting the app I user browser.close()
What is this callback (before quitting)? Im using pure dart and having some problem to check if the program is finishing
And, how are you getting the browser instance to close it?
onBrowserCreated: (Browser? browser) {
_browser = browser;
- I just added a QUIT button in my app
- to get the browser instance, there is a callback on the connect method, like this:
onBrowserCreated: (Browser? browser) { _browser = browser;
Sad for me, cause Im doing console application with pure dart, without button. So idk how can I close the browser
If you just want to close the browser use the close() method on the browser instance you got from the callback
Sad for me, cause Im doing console application with pure dart, without button. So idk how can I close the browser
You can try a workaround Save browsers pid locally, and when you run the program again Just call first 'Process.kill(pid)' This will make sure that only single browser instance will be live when working Or if you want to run the process with hot reload Then save browsers wsEndpoint url locally And pass that parameter in connect method So this will first run the browser And second time on hot restart connect with browser using wsUrl If you saved this url locally on first connect
To save locally you can use any library like hive or something
This will not solve the exact issue, which is actually from puppeteer, it's not closing the chrome on stopping program So you can try these workarounds, atleast this will save you from running multiple chrome instances on each launch And also I noticed that auth works fine in headless mode if we make sure only single chrome instance is running I will try to update example with these changes
Sad for me, cause Im doing console application with pure dart, without button. So idk how can I close the browser
You can try a workaround Save browsers pid locally, and when you run the program again Just call first 'Process.kill(pid)' This will make sure that only single browser instance will be live when working Or if you want to run the process with hot reload Then save browsers wsEndpoint url locally And pass that parameter in connect method So this will first run the browser And second time on hot restart connect with browser using wsUrl If you saved this url locally on first connect
To save locally you can use any library like hive or something
This will not solve the exact issue, which is actually from puppeteer, it's not closing the chrome on stopping program So you can try these workarounds, atleast this will save you from running multiple chrome instances on each launch And also I noticed that auth works fine in headless mode if we make sure only single chrome instance is running I will try to update example with these changes
Getting the same error too.
Really a struggle to even being able to reconnect after Error: [ WhatsappException type : WhatsappExceptionType.failedToConnect , message : Failed to initialize WPP ]
shows up..!
Getting the same error too.
Really a struggle to even being able to reconnect after
Error: [ WhatsappException type : WhatsappExceptionType.failedToConnect , message : Failed to initialize WPP ]
shows up..!
On which platform you are trying ? Is it Flutter web, Desktop or pure dart project ?
Getting the same error too. Really a struggle to even being able to reconnect after
Error: [ WhatsappException type : WhatsappExceptionType.failedToConnect , message : Failed to initialize WPP ]
shows up..!On which platform you are trying ? Is it Flutter web, Desktop or pure dart project ?
Pure dart in console
Impossible to reconnect to the account, after I try to scan the QR code it waits for 1 min and then always give the error:
[...]
ConnectionEvent.authenticated
ConnectionEvent.connecting
Error: Phone not connected
ERROR - 2023-07-06 15:26:24.973291
Asynchronous error
Phone not connected
Impossible to reconnect to the account, after I try to scan the QR code it waits for 1 min and then always give the error:
[...] ConnectionEvent.authenticated ConnectionEvent.connecting Error: Phone not connected ERROR - 2023-07-06 15:26:24.973291 Asynchronous error Phone not connected
You can try to run without headless mode to see whats going on in browser Seems like whatsappWeb not connecting with the phone
- I just added a QUIT button in my app
- to get the browser instance, there is a callback on the connect method, like this:
onBrowserCreated: (Browser? browser) { _browser = browser;
Hello @arytbk how to implement this.... i need close the instance to avoid to do a new request QR
Like this:static Future
I just added a QUIT button in my app to get the browser instance, there is a callback on the connect method, like this:
onBrowserCreated: (Browser? browser) { _browser = browser;
Hello @arytbk how to implement this.... i need close the instance to avoid to do a new request QR
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
same issue occuring in windows now, unable to connect a one time