Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run the new v0.17 wechaty? #1440

Closed
suntong opened this issue Jul 2, 2018 · 19 comments
Closed

How to run the new v0.17 wechaty? #1440

suntong opened this issue Jul 2, 2018 · 19 comments
Labels

Comments

@suntong
Copy link
Contributor

suntong commented Jul 2, 2018

Provide Your Network Information

  1. Where is the location of your server? (i.e. City, or In/Out China) Out China
  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using? None. My Home Internet.

Problem

Having went through the following,

FAQ part : https://github.com/Chatie/wechaty/wiki/FAQ#11-how-to-run-a-new-wecahty-puppet-padchat
Puppet part: https://github.com/Chatie/wechaty/wiki/Puppet#2-run

I'm still unable to make the new v0.17 wechaty working for me.

  • My node, npm, & wechaty are all fresh installs. wechaty's full installation log is at https://pastebin.com/BUeuthqb
  • The examples are just the examples from github.com/Chatie/wechaty latest git.

Full Output Logs

$ node -v
v10.5.0

$ npm -v
6.1.0

$ WECHATY_LOG=silly npm run ts-node ding-dong-bot.ts 
$ WECHATY_LOG=silly node the-worlds-shortest-chatbot-code-in-6-lines.js 
. . . See "Show Logs" for details . . .
Show Logs

Paste the full output logs here with WECHATY_LOG=silly set

$ apt-cache policy nodejs
nodejs:
  Installed: 10.5.0-1nodesource1
  Candidate: 10.5.0-1nodesource1
  Version table:
 *** 10.5.0-1nodesource1 500
        500 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages
        100 /var/lib/dpkg/status
     8.10.0~dfsg-2 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

# PASTE FULL LOG OUTPUT AT HERE:
$ WECHATY_LOG=silly npm run ts-node ding-dong-bot.ts 

> wechaty@0.17.74 ts-node /path/to/nodejs/wechaty
> ts-node "ding-dong-bot.ts"


/usr/lib/node_modules/ts-node/src/index.ts:222
    throw new TSError(formatDiagnostics(configDiagnostics, cwd, ts, 0))
          ^
TSError: ⨯ Unable to compile TypeScript
Unknown compiler option 'declarationMap'. (5023)
Unknown compiler option 'resolveJsonModule'. (5023)
    at Object.register (/usr/lib/node_modules/ts-node/src/index.ts:222:11)
    at Object.<anonymous> (/usr/lib/node_modules/ts-node/src/bin.ts:103:17)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:240:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wechaty@0.17.74 ts-node: `ts-node "ding-dong-bot.ts"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wechaty@0.17.74 ts-node script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tong/.npm/_logs/2018-07-02T22_43_15_710Z-debug.log



$ WECHATY_LOG=silly node the-worlds-shortest-chatbot-code-in-6-lines.js 
18:45:32 SILL Config WECHATY_LOG set level to silly
18:45:32 INFO Config registering process.on("unhandledRejection") for development/debug
18:45:32 VERB Config constructor()
Error: Cannot find module 'wechaty-puppet-mock'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/lfs/cache12/my-caches/repo/gitwork/node_modules/wechaty/dist/src/puppet-config.js:3:31)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/lfs/cache12/my-caches/repo/gitwork/node_modules/wechaty/dist/src/wechaty.js:45:25)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/lfs/cache12/my-caches/repo/gitwork/node_modules/wechaty/dist/src/index.js:14:19)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/lfs/cache12/my-caches/repo/gitwork/nodejs/wechaty/examples/the-worlds-shortest-chatbot-code-in-6-lines.js:19:21)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:240:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)

$ npm run the-worlds-shortest-chatbot-code-in-6-lines.js 
npm ERR! missing script: the-worlds-shortest-chatbot-code-in-6-lines.js
@huan
Copy link
Member

huan commented Jul 3, 2018

You are lucky that I had just rewrite our getting-started repository at https://github.com/lijiarui/wechaty-getting-started

Please try to follow README over there, I believe you can get your bot up very quickly.

If you still have any issue with the getting-started repo, please leave a reply in this thread, so that I'll be able to help you to fix that.

@huan huan added the question label Jul 3, 2018
@suntong
Copy link
Contributor Author

suntong commented Jul 3, 2018

Sweet! Yep, it works out of the box just fine!

Thanks for providing such "for dummy" version of the getting-started guide!

@suntong suntong closed this as completed Jul 3, 2018
@huan
Copy link
Member

huan commented Jul 3, 2018

You are welcome.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

after the above warning, such Message#Text printing will no longer be there, no matter how many test messages I sent afterwards.

This issue should be fixed on Wechaty v0.17.116 or above.

I gave it a try, but it seems to be worse:

$ node examples/starter-bot.js
21:01:34 INFO Wechaty start() v0.17.116 is starting...
21:01:34 INFO Wechaty initPuppet() using puppet: wechat4u
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)
21:01:35 ERR Wechaty start() exception: puppetInstance.setMemory is not a function
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)

FTR, here is how I did the upgrade:

$ npm outdated
Package      Current    Wanted  Latest  Location
@types/node   10.5.1    10.5.2  10.5.2  wechaty-getting-started
wechaty      0.17.75  0.17.116  0.16.5  wechaty-getting-started

$ npm install
audited 915 packages in 5.946s
found 0 vulnerabilities

$ npm outdated
Package      Current    Wanted  Latest  Location
@types/node   10.5.1    10.5.2  10.5.2  wechaty-getting-started
wechaty      0.17.75  0.17.116  0.16.5  wechaty-getting-started

$ npm install wechaty@next
+ wechaty@0.17.116
added 9 packages from 4 contributors, removed 218 packages, updated 6 packages and audited 338 packages in 15.928s
found 0 vulnerabilities

$ npm outdated
Package       Current    Wanted  Latest  Location
@types/node    10.5.1    10.5.2  10.5.2  wechaty-getting-started
wechaty      0.17.116  0.17.116  0.16.5  wechaty-getting-started

@huan
Copy link
Member

huan commented Jul 10, 2018

Sorry, I'm testing the Wechaty with the default puppet with PuppetWechat4u, and when you run without specifying the puppet, the wechat4u will be the default, which has lots of bugs right now.

Please try to use PuppetPuppeteer by:

WECHATY_PUPPET=puppeteer npm start

Please let me know if it works, thanks.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

Oh, thanks for the swift reply.

still not working, basically same error puppetInstance.setMemory is not a function:

$ WECHATY_PUPPET=puppeteer node examples/starter-bot.js
21:30:39 INFO Wechaty start() v0.17.116 is starting...
21:30:39 INFO Wechaty initPuppet() using puppet: puppeteer
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)
21:30:40 ERR Wechaty start() exception: puppetInstance.setMemory is not a function
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)

@huan
Copy link
Member

huan commented Jul 10, 2018

Please do

rm -fr node_modules
rm -f package-lock.json
npm install

Then try again.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

would that install wechaty v0.14 or v0.17? I presume it'll be v0.14, right?

@huan
Copy link
Member

huan commented Jul 10, 2018

No, that should install wechaty@0.17 because you should already save the wechaty@next to the package.json.

There's a bug(I just created) in Wechaty that will cause this issue, the workaround is to install the latest version of node_modules by hand.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

Gotya. thx.

Just tried it, still no go:

rm -fr node_modules
rm -f package-lock.json

$ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
added 147 packages from 160 contributors and audited 338 packages in 19.564s
found 0 vulnerabilities

$ WECHATY_PUPPET=puppeteer node examples/starter-bot.js
21:39:37 INFO Wechaty start() v0.17.117 is starting...
21:39:37 INFO Wechaty initPuppet() using puppet: puppeteer
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)
21:39:38 ERR Wechaty start() exception: puppetInstance.setMemory is not a function
TypeError: puppetInstance.setMemory is not a function
    at Wechaty.<anonymous> (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:387:28)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:4:58)

$ npm outdated
Package   Current    Wanted  Latest  Location
wechaty  0.17.117  0.17.117  0.16.5  wechaty-getting-started

@huan
Copy link
Member

huan commented Jul 10, 2018

Sorry for that.

Please do a

npm i wechaty-puppet@latest
npm i wechaty-puppet-puppeteer@latest

then try again. I believe this time it should work.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

The good news is that I got the wechaty-puppet-padchat working, but won't be long before hitting the wall:

21:45:32 WARN PadchatRpc WXQRCodeLogin, redirect 301
Contact<me> login
...
21:47:57 ERR Contact ready() this.puppet.contactPayload(Contact) exception: WebSocket is not open: readyState 2 (CLOSING)

Good thing is that it can resume by itself:

21:47:58 ERR Contact ready() this.puppet.contactPayload(Contact) exception: WebSocket is not open: readyState 2 (CLOSING)
21:47:58 WARN PadchatRpc initWebSocket() ws.on(close) 1005
21:47:58 WARN PuppetPadchat startManager() manager.on(reset) for ws.on(close, 1005. Restarting PuppetPadchat ... 
Contact<me> logout
21:47:58 WARN PuppetPadchatManager startCheckScan() checkScanLoop() exception: Error: WebSocket is not open: readyState 3 (CLOSED)
21:47:58 WARN PuppetPadchat startManager() manager.on(reset) for startCheckScan() checkScanLoop() exception. Restarting PuppetPadchat ... 
Contact<me> login

I'll try back WECHATY_PUPPET=puppeteer next...

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

npm i wechaty-puppet-puppeteer@latest
then try again. I believe this time it should work.

Yep, WECHATY_PUPPET=puppeteer is working now, and WECHATY_PUPPET=mock had always been working.

So, so far all WECHATY_PUPPET types I tested are working. Super!

@suntong suntong closed this as completed Jul 10, 2018
@huan
Copy link
Member

huan commented Jul 10, 2018

Thank you very much!

@suntong suntong reopened this Jul 10, 2018
@suntong suntong closed this as completed Jul 10, 2018
@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

Just that with wechaty-puppet-padchat, it seems that the communication is in "batch mode" -- for a very long time, no update at all (while updates happening all the time at the WX side), then all of the sudden, all updates show up at once at the script side.

@huan
Copy link
Member

huan commented Jul 10, 2018

Yes, that's depends the server implementation.

What our puppet did is only to follow the protocol and react as needed.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

I just followed the above instruction to do a fresh installation on a brand-new machine, but got:

$ WECHATY_PUPPET=puppeteer node examples/starter-bot.js
23:31:48 INFO Wechaty start() v0.17.117 is starting...
23:31:48 INFO Wechaty initPuppet() using puppet: puppeteer
23:31:48 ERR PuppetPuppeteerBridge start() exception: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

23:31:48 ERR PuppetPuppeteer initBridge() exception: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

Error: no page
    at Bridge.<anonymous> (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/bridge.js:253:23)
    at Generator.next (<anonymous>)
    at /sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/bridge.js:26:71
    at new Promise (<anonymous>)
    at __awaiter (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/bridge.js:22:12)
    at Bridge.stop (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/bridge.js:250:16)
    at PuppetPuppeteer.<anonymous> (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:219:35)
    at Generator.throw (<anonymous>)
    at rejected (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:23:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)
23:31:48 ERR PuppetPuppeteer start() exception: Error: Error: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

Error: Error: Error: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

    at PuppetPuppeteer.puppet.on.error (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:414:44)
    at PuppetPuppeteer.emit (events.js:182:13)
    at PuppetPuppeteer.EventEmitter.emit (domain.js:442:20)
    at PuppetPuppeteer.emit (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet/dist/src/puppet.js:161:22)
    at PuppetPuppeteer.<anonymous> (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:106:22)
    at Generator.throw (<anonymous>)
    at rejected (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:23:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)
23:31:48 ERR Wechaty start() exception: Error: Error: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

Error: Error: Error: Error: Failed to launch chrome!
/sysvol/gt/nodejs/wechaty-getting-started/node_modules/puppeteer/.local-chromium/linux-564778/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


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

    at PuppetPuppeteer.puppet.on.error (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty/dist/src/wechaty.js:414:44)
    at PuppetPuppeteer.emit (events.js:182:13)
    at PuppetPuppeteer.EventEmitter.emit (domain.js:442:20)
    at PuppetPuppeteer.emit (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet/dist/src/puppet.js:161:22)
    at PuppetPuppeteer.<anonymous> (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:106:22)
    at Generator.throw (<anonymous>)
    at rejected (/sysvol/gt/nodejs/wechaty-getting-started/node_modules/wechaty-puppet-puppeteer/dist/src/puppet-puppeteer.js:23:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Does puppeteer provides its own chrome? (I don't have chrome installed on this brand-new machine)

@huan
Copy link
Member

huan commented Jul 10, 2018

That's a problem that the puppeteer must start chrome to provide it's function.

So you need to install all the libraries that the chrome is required first.

@suntong
Copy link
Contributor Author

suntong commented Jul 10, 2018

Ah~~~, gotya! Make sense.

... and yes, it is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants