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

时间:2021-05-23 17:27:06

标签: node.js heroku chatbot whatsapp

我正在构建一个聊天机器人 whattsapp 并部署在 heroku 中。但我是但我卡在那个点

enter image description here

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"
  }
}

我已经按照这些步骤操作了,但还是有错误

<块引用>

在 Heroku 上运行 Puppeteer 在 Heroku 上运行 Puppeteer 需要一些 未包含在 Linux 盒中的其他依赖项 Heroku 为您启动。要在部署上添加依赖项,请添加 Puppeteer Heroku buildpack 到您的应用程序的 buildpack 列表 在“设置”>“构建包”下。

buildpack 的 url 是 https://github.com/jontewks/puppeteer-heroku-buildpack

确保您在启动 Puppeteer 时使用“--no-sandbox”模式。 这可以通过将其作为参数传递给 .launch() 调用来完成: puppeteer.launch({ args: ['--no-sandbox'] });.

当您单击添加 buildpack 时,只需将该 URL 粘贴到输入中, 并点击保存。在下一次部署时,您的应用程序还将安装 Puppeteer 需要运行的依赖项。

如果您需要渲染中文、日文或韩文字符,您可以 需要使用带有其他字体文件的 buildpack,例如 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 个答案:

答案 0 :(得分:1)