Closed CreativeWarlock closed 3 years ago
Hi @CreativeWarlock,
Feel free to add any missing docs with a PR, Anyway when a node is missing it is automatically reported by node red and it's quite easy to install it. About your error you should check it on pupeteer to see what is causing it, it's working flawless on my instance
Thanks for your really fast reply. Here's an excerpt of the log from that installation:
2020-11-04T21:09:36.198Z [out] Chromium (756035) downloaded to /data/node_modules/puppeteer/.local-chromium/linux-756035
2020-11-04T21:09:38.190Z [err] npm
2020-11-04T21:09:38.191Z [err] WARN notsup Unsupported engine for @open-wa/wa-automate@1.9.105: wanted: {"node":">=12.18.3"} (current: {"node":"10.22.1","npm":"6.14.6"})
2020-11-04T21:09:38.191Z [err] npm
2020-11-04T21:09:38.191Z [err] WARN
2020-11-04T21:09:38.191Z [err]
2020-11-04T21:09:38.191Z [err] notsup Not compatible with your version of node/npm: @open-wa/wa-automate@1.9.105
I'm not sure what node is required to be in version >=12.18.3. Could you enlighten me? :)
Like the log says, install node js 12 latest or nodejs 14/15
Good evening,
I have
Still the dashboard does not show any QR image.
Meanwhile every few seconds the following error is shown in the logging/debug tab:
Error while starting Whatsapp client "MyWhatsAppSession": Failed to launch the browser process! spawn /data/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
Looks like it's correlated to this bug here: https://github.com/puppeteer/puppeteer/issues/5992
Unfortunately I can't find a node-red docker image with nodejs in version 14/15..
Or do you have any ideas for a workaround?
Cheers, Marcel
I think that the installation process fails the installation of chrome. Do you install the bot node using the bash or node red web ui? Check install logs to see what happens, install the node using bash
Daniel
On 5 Nov 2020, at 22:33, Marcel Fitzner notifications@github.com wrote:
 Good evening,
I have
updated my node-red docker image to Latest 12 (NODE_VERSION: 12.19.0, YARN_VERSION: 1.22.5, NODE_RED_VERSION: v.1.2.2) started with a fresh local data folder -> Hence I re-installed all nodes over again and watched the logging output. All nodes were installed nicely and with zero errors. The only warning was reimported your Whatsapp-Dashboard flow Still the dashboard does not show any QR image.
Meanwhile every few seconds the following error is shown in the logging/debug tab:
Error while starting Whatsapp client "MyWhatsAppSession": Failed to launch the browser process! spawn /data/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
Do you have any ideas what's potentially wrong?
Cheers, Marcel
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
So I deinstalled Whatsappbot and re-installed it into my node-red docker container. Log output on the console looks as follows:
`bash-5.0$ npm install node-red-contrib-whatsappbot
sharp@0.26.2 install /usr/src/node-red/node_modules/sharp
(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linuxmusl-x64.tar.br
puppeteer@5.4.1 install /usr/src/node-red/node_modules/@open-wa/wa-automate/node_modules/puppeteer
node install.js
Downloading Chromium r809590 - 129.6 Mb [====================] 100% 0.0s
Chromium (809590) downloaded to /usr/src/node-red/node_modules/@open-wa/wa-automate/node_modules/puppeteer/.local-chromium/linux-809590
puppeteer@3.3.0 install /usr/src/node-red/node_modules/puppeteer
node install.js
Downloading Chromium r756035 - 125.2 Mb [= ] 6% 20.6s Downloading Chromium r756035 - 125.2 Mb [= ] 6% 20
Downloading Chromium r756035 - 125.2 Mb [====================] 100% 0.0s
Chromium (756035) downloaded to /usr/src/node-red/node_modules/puppeteer/.local-chromium/linux-756035
npm notice created a lockfile as package-lock.json. You should commit this file.
43 packages are looking for funding
run npm fund
for details
found 3 moderate severity vulnerabilities
run npm audit fix
to fix them, or npm audit
for details`
(I fixed those 3 nodes then, but they were unrelated to your WAbot)
After a restart of the docker the Whatsappbot node appears in node-red, I reattached a new session to the node, and reloaded the UI / dashboard, but sadly it is still missing a QR code.
Do I need any other nodes like a specific QR node? Or any other requirements?
Best regards!
Do I need any other nodes like a specific QR node? Or any other requirements?
Nope the QR just needs the node-red-dashboard node, if there are missing nodes in your configuration node red deploy would fail. Could you add some debug output, maybe after the whatsapp bot node to see what 's the messages that it outputs?
After that send me a screenshot of the node-red debug window (it' on the right side of the editor, just select the debug tab)
So far that's the debug output when I use the Send Message button in the Dashboard.
Also, when I remove the WAbot from the flow and redeploy, the error "Error while starting Whatsapp client 'MyWhatsAppSession'" is continuously added to the debug output. Looks like there's a task in the background running which doesn't stop when I remove the Whatsapp flow. Maybe that is also the reason why I can't deinstall the whatsapp-node from the node-red gui; it only allows me to deactivate.
If it's an option for you I can offer a TeamViewer session with you, which could allow a more fluid approach to look into the issue.
Cheers, Marcel
I think there could be 2 reason that can cause this, have you enabled the flag “use chrome” in client configuration? If so try to disable it.
Alternatively try to install chromium on your docker container “apt-get install chromium-browser” and retry with the chrome flag enabled
Daniel
On 6 Nov 2020, at 13:02, Marcel Fitzner notifications@github.com wrote:

So far that's the debug output when I use the Send Message button in the Dashboard.
If that's an option for you we could go with a TeamViewer session.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Sorry, I'm coming from a Synology environment with a Docker GUI where I've installed a Node-Red container. If you could point me to the file in the NR instance I should be looking at, I can check if the flag is set or not.
It's not a flag in a file, It's a option in whatsapp bot client node. You edit it from the node red editor
I never got to see that Client node anywhere. Its not in the palette. Could it be related to the error message from above?
I tried to deinstall the WAbot-node, but it seems not to be possible anymore. Guess I have to reset the node red container tonight, so I can check where this client node is. Any chance to get more verbose output when I install your WAbot through npm?
Before trying anything else try to install chromium browser from bash and check if it works in this way
Daniel
On 6 Nov 2020, at 18:17, Marcel Fitzner notifications@github.com wrote:
 I never got to see that Client node anywhere. Its not in the palette. Could it be related to the error message from above?
I tried to deinstall the WAbot-node, but it seems not to be possible anymore. Guess I have to reset the node red container tonight, so I can check where this client node is. Any chance to get more verbose output when I install your WAbot through npm?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Went with npm install --save chromium according to https://www.npmjs.com/package/chromium then restarted my Node-Red container, but the error remains.
Install chromium with apt not npm. "sudo apt get install chromium browser"
The image I took (https://registry.hub.docker.com/r/nodered/node-red/) is obviously not equipped with apt. No idea if I can to fix this in this image, but I'm not able to spend time to learn all my missing linux skills while my project has many other fronts to take care of. Going to try with the latest node-red image (rather than 12), but hopes are low.
Here's what happened on my shell with the latest node-red container image:
`bash-5.0$ npm install chromium browser
chromium@3.0.2 postinstall /usr/src/node-red/node_modules/chromium node install.js
Step 1. Retrieving Chromium revision number Step 2. Downloading Chromium revision 825071 Downloading Chromium - 133.4 MB [====================] 100% 0.0s Step 3. Setting up Chromium binaries Process is successfully finished npm notice created a lockfile as package-lock.json. You should commit this file.
10 packages are looking for funding
run npm fund
for details
found 3 moderate severity vulnerabilities
run npm audit fix
to fix them, or npm audit
for details
bash-5.0$ npm i puppeteer
puppeteer@5.4.1 install /usr/src/node-red/node_modules/puppeteer node install.js
Downloading Chromium r809590 - 129.6 Mb [====================] 100% 0.0s Chromium (809590) downloaded to /usr/src/node-red/node_modules/puppeteer/.local-chromium/linux-809590
12 packages are looking for funding
run npm fund
for details
found 3 moderate severity vulnerabilities
run npm audit fix
to fix them, or npm audit
for details
bash-5.0$ npnpm config set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD false
bash-5.0$ npm config set ignore-scripts false
bash-5.0$ npm install node-red-contrib-whatsappbot
sharp@0.26.2 install /usr/src/node-red/node_modules/sharp (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linuxmusl-x64.tar.br
puppeteer@3.3.0 install /usr/src/node-red/node_modules/node-red-contrib-whatsappbot/node_modules/puppeteer node install.js
Downloading Chromium r756035 - 125.2 Mb [====================] 100% 0.0s Chromium (756035) downloaded to /usr/src/node-red/node_modules/node-red-contrib-whatsappbot/node_modules/puppeteer/.local-chromium/linux-756035 npm WARN notsup Unsupported engine for @open-wa/wa-automate@3.0.13: wanted: {"node":">=12.18.3"} (current: {"node":"10.23.0","npm":"6.14.8"}) npm WARN notsup Not compatible with your version of node/npm: @open-wa/wa-automate@3.0.13
As you an see, on installing your whatsapp bot it pulled another older chromium into the '.local-chromium' subfolder of puppeteer. Is there a way to update that local chromium in any way?
This one adds some more light into the problem:
`bash-5.0$ npm install puppeteer-chromium-resolver --save
puppeteer-chromium-resolver@5.2.0 install /usr/src/node-red/node_modules/puppeteer-chromium-resolver node install.js
[PCR] Chromium revision: 809590 [PCR] Not found local chromium
Monitoring:https://storage.googleapis.com Time: 2020-11-07 00:14:46
Monitoring:https://npm.taobao.org/mirrors Time: 2020-11-07 00:14:46
[PCR] Downloading from host: https://npm.taobao.org/mirrors ... [PCR] Chromium downloaded to /usr/src/node-red/.chromium-browser-snapshots [PCR] Checking previous local chromium revisions ... Error: Failed to launch the browser process! spawn /usr/src/node-red/.chromium-browser-snapshots/linux-809590/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/usr/src/node-red/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at ChildProcess.helper_js_1.helper.addEventListener (/usr/src/node-red/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:185:85)
at ChildProcess.emit (events.js:198:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
[PCR] Chromium launchable: false [PCR] Puppeteer version: 5.4.1 [PCR] Stats saved: .stats.json npm WARN notsup Unsupported engine for ping-monitor@0.5.1: wanted: {"node":">=12.x","npm":">=1.3.x"} (current: {"node":"10.23.0","npm":"6.14.8"}) npm WARN notsup Not compatible with your version of node/npm: ping-monitor@0.5.1
45 packages are looking for funding
run npm fund
for details
found 3 moderate severity vulnerabilities
run npm audit fix
to fix them, or npm audit
for details`
Further investigating..
Sorry @CreativeWarlock I never saw such problems on my instances. What I still saw is:
Unsupported engine for ping-monitor@0.5.1: wanted: {"node":">=12.x","npm":">=1.3.x"} (current: {"node":"10.23.0","npm":"6.14.8"})
I think your container is still using a nodejs 10. My suggestion is to edit node red dockerfile to use nodejs 12 (it's in the first line FROM nodexx
.
I don't see any other error in your bash output. If you are still not able to fix it I will provide you a Dockerfile
You could start from this: https://github.com/node-red/node-red-docker/blob/master/.docker/Dockerfile.alpine
And add node 14 build arg
bash-5.0$ nodejs --version v10.23.0
Indeed!
Thanks for your link, I'll have a look into it tonight
You welcome, let me know!
Daniel
On 7 Nov 2020, at 12:54, Marcel Fitzner notifications@github.com wrote:
 bash-5.0$ nodejs --version v10.23.0
Indeed! Thanks, I'll try to get this one running.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Hi mate, I'm wondering - I see no tag 14 when I go to their summary page https://github.com/node-red/node-red-docker - or am I blind? :) So how would I download this dockerfile from that gitHub page? Sorry to bug you with those stupid newbie questions..
Hi, I am havng the same issue. I am running node red from docker nodered/node-red:latest-12
, so the node version is v12.19.0
.
After installing the dashboard and table dependencies, no QR is displayed and the following error appears on debug:
Error while starting Whatsapp client "session": Failed to launch the browser process! spawn /data/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
The only similar error shown on that link states:
This means that the browser was downloaded but failed to be extracted correctly. The most common cause is a bug in Node.js v14.0.0 which broke extract-zip, the module Puppeteer uses to extract browser downloads into the right place. The bug was fixed in Node.js v14.1.0, so please make sure you're running that version or higher. Alternatively, if you cannot upgrade, you could downgrade to Node.js v12, but we recommend upgrading when possible.
My node version is 12, so clearly this is not the cause of the issue.
Hi guys,
Based on what you are telling me I can say that it’s not something strictly related to this package but something nodejs/puppeteer related. Another think you could try to do is to install another version of pupetteer with
npm install puppeteer@latest
on the node-red folder
The puppeteer version I’m using on this package is some major version old because I had some bugs with latest version with session restore. Try this and let me know :)
About the nodejs version you should download that dockerfile and manually build the container using docker build command and passing the nodejs 14 build arg
Daniel
On 8 Nov 2020, at 01:59, Juan Gonzalez Burgos notifications@github.com wrote:
 Hi, I am havng the same issue. I am running node red from docker nodered/node-red:latest-12, so the node version is v12.19.0 .
After installing the dashboard and table dependencies, no QR is displayed and the following error appears on debug:
Error while starting Whatsapp client "session": Failed to launch the browser process! spawn /data/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md The only similar error shown on that link states:
This means that the browser was downloaded but failed to be extracted correctly. The most common cause is a bug in Node.js v14.0.0 which broke extract-zip, the module Puppeteer uses to extract browser downloads into the right place. The bug was fixed in Node.js v14.1.0, so please make sure you're running that version or higher. Alternatively, if you cannot upgrade, you could downgrade to Node.js v12, but we recommend upgrading when possible. My node version is 12, so clearly this is not the cause of the issue.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Another alternative could be to downnload chromium using:
sudo apt-get install chromium-browser
And then start node-red using the env var PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
. This will tell puppeteer to use the local installed chromium instead of the downloaded
What I did is:
docker exec -it --user=root nodered /bin/bash
apk add chromium
which chromium-browser
# /usr/bin/chromium-browser
cd /data/node_modules/puppeteer/.local-chromium/linux-809590/chrome-linux/
mv chrome chrome_bk
ln -s /usr/bin/chromium-browser ./chrome
Now the QR code appears in red. I still get some errors in the debug:
And in the UI console:
Are they normal? I will try to investigate further.
@juangburgos If the qr appears it means the browser thing now it's fixed. Why it's red it depends on the wa automate updates that maybe made some changes in the base64 qr image (but it works even if it's red). About the console error try to add a debug after the whatsapp client to see what's the output
I have also released a new version 0.2.2 where you can enable useChrome
and inDocker
flags of wa automate
I tried restarting everything. But still after scanning the QR, no success. The whatsapp connection seems to be changing state like crazy from PAIRING
to CONNECTED
. On my phone when I see the borwser sessions also keeps changing state very fast:
Hi, I restarted the docker a couple of times, and now seems to be working. At least I receive messages, but I cannot send messages. For example, I have a group and when I get a new message, the table shows:
FROM - TEXT
xxxxxxxxxx@c.us - hola
Then if I try to send a message to xxxxxxxxxx@c.us
nothing happens.
Are you using the original wa-automate-nodejs
API behind the scenes? Because I see on their API that the function to send text is sendText
, but in you example you use sendMessageToId
, I dont know if this might be the issue?
@juangburgos The sendMessageToId
is a bonus api I have patched in my package but could be broken at any time (wa update or whatsapp updates). The reason why I added it is because wa automate requests a pay license to send messages to unknown ids, essentially that is the function used to do that but as said it may be broken now (would require to enable dev tools and check what's going on there).
If you have to send messages to known contacts use sendText
api that should always work!
About your problem with the socket, I saw that and most times is caused by browser/puppeteer/wa automate session incompatibilities, usually I fix by deleting session data in .node-red
directory, other times need to update puppeteer and/or chromium
@robertsLando thank you for your help, but I think I am just gonna give up. Every time I think I am making progress, new errors appear. Or the socker error comes back and I have to restart the docker quite often. Hopefully this becomes more reliable on the future as it would be very useful. Thanks again.
@juangburgos did you try to run this in a local machine instead of a docker container?
I ran everything in docker, because that is what I need.
I now had success reading and writing to whatsapp using the node-red-contrib-function-npm
in conjunction with the original wa-automate-nodejs
API.
I just create a function with the content:
const wa = require('@open-wa/wa-automate');
var wa_client = flow.get('wa_client');
if(!wa_client) {
wa.create().then((wa_client) => {
console.log('wa_client created');
wa_client.onMessage((message) => {
console.log(`message = ${JSON.stringify(message)}`);
msg.payload = message;
node.send(msg);
if (message.body === 'Hi') {
wa_client.sendText(message.from, 'đź‘‹ Hello!');
}
});
flow.set('wa_client', wa_client);
});
}
// other stuff ...
return null;
The QR code appears in the console, which works better for me because I don't need the ui dependency.
With this approach I still get the puppeteer issue we discussed above, but with the chrome fix we discussed, it works like a charm, no socket erros and seems quite reliable.
So for the time being, I guess I will stick to this.
@juangburgos This is what I do too in the code: https://github.com/robertsLando/node-red-contrib-whatsappbot/blob/master/client.js#L41
I don't understand what's going on there
@juangburgos Did you try to use the latest version 0.2.3? Because I'm not able to reproduce such problems with that version
I can also confirm that the sendMessageToId
is still working with wa-automate latest version.
@CreativeWarlock @juangburgos I'm closing this for now as seems fixed on latest version. Fell free to reopen it if you still face this bug
Hi mate,
I'd like to kindly suggest to add some more information on your documentation landing page, for example, when I installed your node it could not find the node-red-dashboard. so having a list of dependencies would be nice.
When I added the missing dependency and called the UI dashboard, I am now looking at a Whatsapp dashboard which is missing the QR code. So how to fix this? Is there another node missing?
The "Whatsapp Bot" node itself throws periodically the following exception:
Error while starting Whatsapp client "session": Failed to launch the browser process! spawn /data/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome ENOENT TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
Besides what are the preconditions to actually run your node? Do I need to have a Whatsapp business account?
Your help would be much appreciated,
Best regards Marcel