Wechaty: Can not run in CentOS server, Error: socket hang up

Created on 16 Sep 2018  ·  4Comments  ·  Source: wechaty/wechaty

1. Error log:

02:44:27 INFO Wechaty start() v0.22.4 is starting...
02:44:28 ERR PuppetPuppeteerBridge start() exception: Error: socket hang up
02:44:28 ERR PuppetPuppeteer initBridge() exception: Error: socket hang up
02:44:28 ERR PuppetPuppeteer initBridge() this.bridge.stop() rejection: Error: no page
02:44:28 ERR PuppetPuppeteer start() exception: Error: Error: Error: socket hang up
Error: Error: Error: Error: socket hang up
at PuppetPuppeteer.puppet.on.error (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/dist/src/wechaty.js:436:44)
at PuppetPuppeteer.emit (events.js:182:13)
at PuppetPuppeteer.EventEmitter.emit (domain.js:442:20)
at PuppetPuppeteer.emit (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty-puppet/dist/src/puppet.js:171:22)
at PuppetPuppeteer. (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:106:22)
at Generator.throw ()
at rejected (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:23:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
02:44:28 ERR Wechaty start() exception: Error: Error: Error: socket hang up
Bot init() fail: %s Error: Error: Error: Error: socket hang up
at PuppetPuppeteer.puppet.on.error (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/dist/src/wechaty.js:436:44)
at PuppetPuppeteer.emit (events.js:182:13)
at PuppetPuppeteer.EventEmitter.emit (domain.js:442:20)
at PuppetPuppeteer.emit (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty-puppet/dist/src/puppet.js:171:22)
at PuppetPuppeteer. (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:106:22)
at Generator.throw ()
at rejected (/root/qingcheng_test/aos/run/node_modules/[email protected]@wechaty/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:23:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2922) UnhandledPromiseRejectionWarning: ReferenceError: param is not defined
at qchat.start.catch (/root/qingcheng_test/aos/run/firstRun.js:14:24)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2922) 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: 3)
(node:2922) [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.

2. code:

const { config, Wechaty, Friendship } = require('wechaty')
let qchat = Wechaty.instance({ profile: config.default.DEFAULT_PROFILE })

qchat
.on('scan', (qrcode, status) => {
console.log('Finish first run');
})

qchat
.start()
.catch(async e => {
console.error('Bot', 'init() fail: %s', e)
await this.robotStop(param);
})

3. Steps

  1. npm i wechaty
  2. show can not download chrome, then npm i puppeteer
  3. copy puppeteer's chrome to wechaty puppeteer's path
  4. node xx.js, show can not found libXxxxx.so. then yum install chrome
  5. node xx.js, show error logs, Error: socket hang up
  6. I use the same step(without step 4/5) success in local macOS.
question

Most helpful comment

We have a CI for CentOS, you can find it at https://circleci.com/gh/Chatie/wechaty

Hope that could help you to fix your problem.

I've solved this issue. In centOS server, use below command to install chrome dependent

Lib

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

Font

yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

All 4 comments

We have a CI for CentOS, you can find it at https://circleci.com/gh/Chatie/wechaty

Hope that could help you to fix your problem.

We have a CI for CentOS, you can find it at https://circleci.com/gh/Chatie/wechaty

Hope that could help you to fix your problem.

Thank you , I'll try it later

We have a CI for CentOS, you can find it at https://circleci.com/gh/Chatie/wechaty

Hope that could help you to fix your problem.

I've solved this issue. In centOS server, use below command to install chrome dependent

Lib

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

Font

yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

Glad to hear that you had fixed the problem.

And thank you very much for sharing the commands under centos!

Was this page helpful?
0 / 5 - 0 ratings