pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
14.96k stars 3.55k forks source link

Run whatsapp-web.js on UBUNTU 20.04 no GUI #510

Closed myhardez closed 3 years ago

myhardez commented 3 years ago

Hi sir

I will ask sir , i try run this on UBUNTU 20.04 no GUI but have error Can I run this on UBUNTU 20.04 no GUI ?

error log

root@wa-server:/whatsapp-api# npm run start

whatsapp-api@1.0.0 start /whatsapp-api node app.js

(node:15485) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! [0109/091009.834081:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/whatsapp-api/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at Interface.helper_js_1.helper.addEventListener (/whatsapp-api/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
at Interface.emit (events.js:203:15)
at Interface.close (readline.js:397:8)
at Socket.onend (readline.js:173:10)
at Socket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

(node:15485) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:15485) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. root@wa-server:/whatsapp-api# node --version v10.19.0 root@wa-server:/whatsapp-api#

mbilgidhis commented 3 years ago

Short answer is yes, you can run on Ubuntu 20.04 with no GUI. I run it with no problems at all. And make sure you had already installed the dependencies mentioned on this link. Take a look at Debian section.

From your log, it seems you run with root user, have you tried using non-root user?

myhardez commented 3 years ago

thank you sir

victormga commented 3 years ago

this is puppeteer/chromium related. to solve it, you need to read about how to enable chromium sandbox on your OS, or run it without sandbox using root.

rmaafs commented 3 years ago

thank you sir

How to solve this?

glbatistabh commented 3 years ago

solution: puppeteer: {headless: true}

        let client = new Client({
          session: session,
          //qrTimeoutMs: 120000,
          //authTimeoutMs: 120000,
          //restartOnAuthFail: true,
          //takeoverOnConflict: true
          //takeoverTimeoutMs: 5000
          puppeteer: {headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-extensions']}
        });
ameybh commented 3 years ago

Simple boilerplate for only terminal instance: ameybhavsar24/ww-bot/index.js

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

myhardez commented 2 years ago

Screenshot_1 const client = new Client({ restartOnAuthFail: true, puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', ], }, session: sessionCfg });

I try again, but have error please help me

i9team commented 2 years ago

Insira essa linha em seu args: '--disable-extensions'

Além disso, você precisa instalar o chromium em seu servidor:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 
sudo dpkg -i google-chrome-stable_current_amd64.deb 
sudo apt-get install -f 

Depois de ter instalado o chromium, você precisa habilita-lo: node node_modules/puppeteer/install.js

Lembre-se que você deve fazer esses passos em sua pasta do projeto onde está rodando o wpp

Lepist commented 2 years ago

Hi guys, can you show your dockerfile with whatsapp-web.js. I have troubles with running application on Ubuntu. Its well work on windows but on Ubuntu doesn't work properly. I saw 2 errors with running whatsapp-web.js on linux: 1) Error: Failed to launch the browser process! /node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

2) ERR_CONNECTION... web.whatsapp.com (application don't send QR in a few minutes and than send error)

BalikLayarID commented 2 years ago

solution: puppeteer: {headless: true}

        let client = new Client({
          session: session,
          //qrTimeoutMs: 120000,
          //authTimeoutMs: 120000,
          //restartOnAuthFail: true,
          //takeoverOnConflict: true
          //takeoverTimeoutMs: 5000
          puppeteer: {headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-extensions']}
        });

This solution work for me on Debian Linux 10... if still not work, try install dependencies based on https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix

SannanOfficial commented 11 months ago

@i9team Yours is the only solution that works here for me, thanks!

SannanOfficial commented 11 months ago

Well, really a combination of all options work 😜

    puppeteer: {
      headless: true,
      ignoreHTTPSErrors: true,
      args: [
        "--no-sandbox",
        "--disable-setuid-sandbox",
        "--disable-extensions",
      ],
    },
Jossymolina commented 9 months ago

image image

Hello, The error no longer appears but now the result does not appear. It just goes black and I don't know what's happening.