whatsapp 聊天机器人不要 运行 在 heroku 中

whatsapp chatbot don't run in heroku

我正在构建一个聊天机器人 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"
  }
}

我已经按照这些步骤操作了,但我仍然遇到错误

Running Puppeteer on Heroku Running Puppeteer on Heroku requires some additional dependencies that aren't included on the Linux box that Heroku spins up for you. To add the dependencies on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your app under Settings > Buildpacks.

The url for the buildpack is https://github.com/jontewks/puppeteer-heroku-buildpack

Ensure that you're using '--no-sandbox' mode when launching Puppeteer. This can be done by passing it as an argument to your .launch() call: puppeteer.launch({ args: ['--no-sandbox'] });.

When you click add buildpack, simply paste that url into the input, and click save. On the next deploy, your app will also install the dependencies that Puppeteer needs to run.

If you need to render Chinese, Japanese, or Korean characters you may need to use a buildpack with additional font files like https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack

There's also another simple guide from @timleland that includes a sample project: https://timleland.com/headless-chrome-on-heroku/.

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

这是答案:我必须创建整个教程才能使其正常工作:

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