чат-бот whatsapp не работает в heroku

#node.js #heroku #chatbot #whatsapp

Вопрос:

Я создаю чат-бота whattsapp и развертываю его в heroku. Но это так, Но я застрял на этом этапе

введите описание изображения здесь

 info:     You're up to date
info:     [session:browser] Initializing browser...
warn:     [session:browser] Chrome not found, using chromium
error:    [session:browser] Error no open browser
error:    [session:browser] Failed to launch the browser process!
[0523/163914.552659:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/ /master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x55853747db39 base::debug::CollectStackTrace()
#1 0x5585373f04c3 base::debug::StackTrace::StackTrace()
#2 0x558537400c80 logging::LogMessage::~LogMessage()
#3 0x558535e92f5e content::ZygoteHostImpl::Init()
#4 0x55853739acf8 content::ContentMainRunnerImpl::Initialize()
#5 0x558537398e0b content::RunContentProcess()
#6 0x558537398f5c content::ContentMain()
#7 0x5585373ea3d2 headless::(anonymous namespace)::RunContentMain()
#8 0x5585373ea0bc headless::HeadlessShellMain()
#9 0x5585349eba03 ChromeMain
#10 0x7f0f848460b3 __libc_start_main
#11 0x5585349eb82a _start

Received signal 6
#0 0x55853747db39 base::debug::CollectStackTrace()
#1 0x5585373f04c3 base::debug::StackTrace::StackTrace()
#2 0x55853747d6db base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f0f860063c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so 0x153bf)
#4 0x7f0f8486518b gsignal
#5 0x7f0f84844859 abort
#6 0x55853747c665 base::debug::BreakDebugger()
#7 0x5585374010f2 logging::LogMessage::~LogMessage()
#8 0x558535e92f5e content::ZygoteHostImpl::Init()
#9 0x55853739acf8 content::ContentMainRunnerImpl::Initialize()
#10 0x558537398e0b content::RunContentProcess()
#11 0x558537398f5c content::ContentMain()
#12 0x5585373ea3d2 headless::(anonymous namespace)::RunContentMain()
#13 0x5585373ea0bc headless::HeadlessShellMain()
#14 0x5585349eba03 ChromeMain
#15 0x7f0f848460b3 __libc_start_main
#16 0x5585349eb82a _start
  r8: 0000000000000000  r9: 00007ffd34ef4aa0 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd34ef5db0 r13: aaaaaaaaaaaaaaaa r14: 00007ffd34ef5dc0 r15: 00007ffd34ef5540
  di: 0000000000000002  si: 00007ffd34ef4aa0  bp: 00007ffd34ef4cf0  bx: 00007f0f834db240
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f0f8486518b  sp: 00007ffd34ef4aa0
  ip: 00007f0f8486518b efl: 0000000000000246 cgf: 0000000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


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

Error: Failed to launch the browser process!
[0523/163914.552659:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/ /master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x55853747db39 base::debug::CollectStackTrace()
#1 0x5585373f04c3 base::debug::StackTrace::StackTrace()
#2 0x558537400c80 logging::LogMessage::~LogMessage()
#3 0x558535e92f5e content::ZygoteHostImpl::Init()
#4 0x55853739acf8 content::ContentMainRunnerImpl::Initialize()
#5 0x558537398e0b content::RunContentProcess()
#6 0x558537398f5c content::ContentMain()
#7 0x5585373ea3d2 headless::(anonymous namespace)::RunContentMain()
#8 0x5585373ea0bc headless::HeadlessShellMain()
#9 0x5585349eba03 ChromeMain
#10 0x7f0f848460b3 __libc_start_main
#11 0x5585349eb82a _start

Received signal 6
#0 0x55853747db39 base::debug::CollectStackTrace()
#1 0x5585373f04c3 base::debug::StackTrace::StackTrace()
#2 0x55853747d6db base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f0f860063c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so 0x153bf)
#4 0x7f0f8486518b gsignal
#5 0x7f0f84844859 abort
#6 0x55853747c665 base::debug::BreakDebugger()
#7 0x5585374010f2 logging::LogMessage::~LogMessage()
#8 0x558535e92f5e content::ZygoteHostImpl::Init()
#9 0x55853739acf8 content::ContentMainRunnerImpl::Initialize()
#10 0x558537398e0b content::RunContentProcess()
#11 0x558537398f5c content::ContentMain()
#12 0x5585373ea3d2 headless::(anonymous namespace)::RunContentMain()
#13 0x5585373ea0bc headless::HeadlessShellMain()
#14 0x5585349eba03 ChromeMain
#15 0x7f0f848460b3 __libc_start_main
#16 0x5585349eb82a _start
  r8: 0000000000000000  r9: 00007ffd34ef4aa0 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd34ef5db0 r13: aaaaaaaaaaaaaaaa r14: 00007ffd34ef5dc0 r15: 00007ffd34ef5540
  di: 0000000000000002  si: 00007ffd34ef4aa0  bp: 00007ffd34ef4cf0  bx: 00007f0f834db240
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f0f8486518b  sp: 00007ffd34ef4aa0
  ip: 00007f0f8486518b efl: 0000000000000246 cgf: 0000000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


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

    at onClose (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at Interface.<anonymous> (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
    at Interface.emit (events.js:388:22)
    at Interface.close (readline.js:429:8)
    at Socket.onend (readline.js:202:10)
    at Socket.emit (events.js:388:22)
    at endReadableNT (internal/streams/readable.js:1336:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

 

robo.js

 const wppconnect = require('@wppconnect-team/wppconnect');
const puppeteer = require('puppeteer');

puppeteer.launch({ args: ['--no-sandbox', '--disable--gpu', '--disable-setuid-sandbox'] });

(async () => {

    try {
        const cliente = await wppconnect.create((cliente) => {
            return cliente

        })
        start(cliente);
    } catch (err) {
        console.log(err)
    }

})()

const start = async (client) => {

    try {
        //usuário manda mensagem
        await client.onMessage(async (message) => {
            console.log('Mensagem digitada pelo usuário: '   message.body);
            console.log("Body "   message)
            //stages(client,message)
            //const result = await client.sendText(message.from, 'PING! Mande um PONG para mim:')

        });
    } catch (err) {
        console.error('Error ', erro)
    }
}
 

package.json

 {
  "name": "robo",
  "version": "1.0.0",
  "description": "",
  "main": "robo.js",
  "scripts": {
    "test": "nodemon robo.js",
    "start": "node robo.js "
  },
  "dependencies": {
    "@wppconnect-team/wppconnect": "^1.5.1",
    "puppeteer": "^5.5.0"
  }
}
 

I already followed these steps and I still have the error

Запуск Puppeteer на Heroku Запуск Puppeteer на Heroku требует некоторых дополнительных зависимостей, которые не включены в коробку Linux, которую Heroku запускает для вас. Чтобы добавить зависимости при развертывании, добавьте пакет сборки Puppeteer Heroku в список пакетов сборки для вашего приложения в разделе Настройки > Пакеты сборки.

URL — адрес пакета сборки: https://github.com/jontewks/puppeteer-heroku-buildpack

Убедитесь, что вы используете режим «—без песочницы» при запуске Puppeteer. Это можно сделать, передав его в качестве аргумента вашему .запуск() вызов: кукловод.запуск({ args: [‘—без песочницы’] });.

Когда вы нажмете добавить пакет сборки, просто вставьте этот URL-адрес во входные данные и нажмите кнопку Сохранить. При следующем развертывании ваше приложение также установит зависимости, необходимые для запуска Puppeteer.

Если вам нужно отобразить китайские, японские или корейские символы, вам может потребоваться использовать пакет сборки с дополнительными файлами шрифтов, такими как https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack

Есть также еще одно простое руководство от @timleland, которое включает в себя пример проекта: https://timleland.com/headless-chrome-on-heroku/.

https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-heroku

Ответ №1:

Вот ответ: мне пришлось создать весь этот учебник, чтобы он работал:

https://medium.com/como-programar-em-1-dia/como-fazer-um-robô-de-whatsapp-chatbot-em-1-dia-644ee98054d7