wechaty / puppet-supports

Wechaty Puppet Services (WPS)
https://wechaty.js.org/docs/puppet-services/
Apache License 2.0
33 stars 4 forks source link

How to use wechaty Rock: Error: 16 UNAUTHENTICATED: token(114.215.83.32:7777) must be prefixed with a 'puppet_rock_' #38

Open suntong opened 3 years ago

suntong commented 3 years ago

Question

How to properly run wechaty-puppet-rock?

0. Report Issue Guide

  1. Please run the following command and check whether the problem has been fixed:

    rm -rf package-lock.json
    rm -rf node_modules
    npm install

    Done.

  2. Please search in FAQ List first, and make sure your problem has not been solved before.

    Done.

  3. Please search in the issue first, and make sure your problem had not been reported before

    Done.

1. Versions

To be specifically,

├─┬ file-box@0.14.3
├─┬ wechaty@0.51.5
│ ├─┬ wechaty-puppet@0.33.6
│ │ ├─┬ file-box@0.16.2
│ ├─┬ wechaty-puppet-hostie@0.11.10
├─┬ UNMET PEER DEPENDENCY wechaty-puppet@0.32.3
│ ├─┬ file-box@0.13.5
├─┬ wechaty-puppet-hostie@0.10.8
├─┬ wechaty-puppet-mock@0.28.1
└─┬ wechaty-puppet-puppeteer@0.22.1
$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal

2. Describe the bug

3. To Reproduce

Steps to reproduce the behavior:

  1. run 'ding-dong-bot.js' from the standard example from wechaty-getting-started

4. Expected behavior

It works.

6. Full Output Logs

Set env WECHATY_LOG=silly in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)

We need full log instead of log screenshot or log fragments!

Show full Logs ```shell $ WECHATY_LOG=silly node ding-dong-bot.js 12:15:53 SILL Puppet Config: WECHATY_LOG set level to silly 12:15:53 INFO Config registering process.on("unhandledRejection") for development/debug 12:15:53 VERB Config constructor() 12:15:53 VERB Wechaty constructor() 12:15:53 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 12:15:53 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 12:15:53 VERB Wechaty on(scan, listener) registered 12:15:53 VERB Wechaty on(login, listener) registered 12:15:53 VERB Wechaty on(logout, listener) registered 12:15:53 VERB Wechaty on(message, listener) registered 12:15:53 VERB Wechaty (ding-dong-bot) start() v0.41.17 is starting... 12:15:53 VERB Wechaty id: ckide..iy 12:15:53 SILL StateSwitch on() is false 12:15:53 SILL StateSwitch off() is true 12:15:53 VERB StateSwitch off(true) <- (true) 12:15:53 SILL StateSwitch on() is false 12:15:53 VERB StateSwitch on(pending) <- (false) 12:15:53 VERB MemoryCard constructor("ding-dong-bot") 12:15:53 VERB MemoryCard getStorage() for storage type: N/A 12:15:53 VERB getStorage name: ding-dong-bot, options: {"type":"file"} 12:15:53 VERB StorageFile constructor(ding-dong-bot, ...) 12:15:53 VERB StorageBackend constructor(ding-dong-bot, { type: file }) 12:15:53 VERB MemoryCard load() from storage: StorageFile 12:15:53 VERB StorageFile load() from /path/to/.../ding-dong-bot.memory-card.json 12:15:53 VERB MemoryCard load() file not exist, NOOP 12:15:53 VERB Wechaty initPuppet() 12:15:53 VERB MemoryCard multiplex(puppet) 12:15:53 VERB MemoryCard static multiplex(MemoryCard, puppet) 12:15:53 VERB MemoryCard constructor({"name":"ding-dong-bot","multiplex":{"name":"puppet","parent":{"options":{"name":"ding-dong-bot"},"name":"ding-dong-bot","payload":{},"multiplexNameList":[],"storage":{"name":"ding-dong-bot","options":{"type":"file"},"absFileName":"/path/to/.../ding-dong-bot.memory-card.json"}}}}) 12:15:53 VERB PuppetManager resolve({puppet: wechaty-puppet-hostie, puppetOptions: undefined}) 12:15:53 VERB PuppetManager resolveName(wechaty-puppet-hostie) 12:15:53 VERB PuppetManager checkModule(wechaty-puppet-hostie) 12:15:53 SILL PuppetManager checkModule() wechaty-puppet-hostie installed version 0.8.3 satisfied range ^0.8.3 12:15:53 VERB Puppet constructor({}) #0 12:15:53 VERB StateSwitch constructor(PuppetHostie, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 12:15:53 VERB MemoryCard constructor(undefined) 12:15:53 VERB MemoryCard getStorage() for storage type: N/A 12:15:53 VERB MemoryCard load() from storage: N/A 12:15:53 VERB MemoryCard load() no storage 12:15:53 VERB Puppet constructor() watchdog timeout set to 60 seconds 12:15:53 VERB HotImport callerResolve(., /../wechaty-getting-started/node_modules/wechaty-puppet/dist/src/puppet.js) 12:15:53 SILL HotImport callerResolve() callsites() file=/../wechaty-getting-started/node_modules/hot-import/dist/src/hot-import.js, type=Object 12:15:53 SILL HotImport callerResolve() callsites() file=/../wechaty-getting-started/node_modules/wechaty-puppet/dist/src/puppet.js, type=null 12:15:53 SILL HotImport callerResolve() callsites() file=/../wechaty-getting-started/node_modules/wechaty-puppet-hostie/dist/src/client/puppet-hostie.js, type=null 12:15:53 SILL HotImport callerResolve() callerFile=/../wechaty-getting-started/node_modules/wechaty-puppet-hostie/dist/src/client/puppet-hostie.js 12:15:53 VERB Puppet constructor() childClassPath=/../wechaty-getting-started/node_modules/wechaty-puppet-hostie/dist/src/client 12:15:53 VERB Puppet constructor() memory.load() done 12:15:53 VERB Puppet setMemory() 12:15:53 VERB Wechaty initPuppetEventBridge(Puppet#0(ding-dong-bot)) 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(login) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(logout) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(message) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(scan) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(dong) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(error) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(heartbeat) (listenerCount:1) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(ready) (listenerCount:0) registering... 12:15:53 VERB Wechaty initPuppetEventBridge() puppet.on(reset) (listenerCount:1) registering... 12:15:53 VERB Wechaty initAccessory(Puppet#0(ding-dong-bot)) 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set wechaty = "Wechaty#ckide0bef0000rufuhrbi8uiy<>(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 12:15:53 VERB PuppetHostie start() 12:15:53 SILL StateSwitch on() is false 12:15:53 SILL StateSwitch on() is false 12:15:53 VERB StateSwitch on(pending) <- (false) 12:15:53 VERB PuppetHostie startGrpcClient() 12:15:53 VERB PuppetHostie startGrpcStream() 12:15:53 ERR PuppetHostie start() rejection: 14 UNAVAILABLE: DNS resolution failed 12:15:53 SILL StateSwitch off() is false 12:15:53 VERB StateSwitch off(true) <- (false) { Error: 14 UNAVAILABLE: DNS resolution failed at Object.exports.createStatusError (/../wechaty-getting-started/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/../wechaty-getting-started/node_modules/grpc/src/client_interceptors.js:1209:28) at InterceptingListener._callNext (/../wechaty-getting-started/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/../wechaty-getting-started/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/../wechaty-getting-started/node_modules/grpc/src/client_interceptors.js:847:24) code: 14, metadata: Metadata { _internal_repr: {}, flags: 0 }, details: 'DNS resolution failed' } 12:15:53 ERR Wechaty start() exception: 14 UNAVAILABLE: DNS resolution failed 12:15:53 ERR StarterBot Error: 14 UNAVAILABLE: DNS resolution failed 12:15:53 VERB PuppetHostie startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: DNS resolution failed 12:15:53 SILL Puppet constructor() this.on(reset) payload: "{"data":"startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: DNS resolution failed"}" 12:15:53 SILL Puppet constructor() resetThrottleQueue.subscribe() reason: "startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: DNS resolution failed" 12:15:53 VERB Puppet reset(startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: DNS resolution failed) 12:15:53 VERB PuppetHostie stop() ```

7. Additional context

No any other context about the problem here.

[bug]

suntong commented 3 years ago

Took a look at the grpc/src/client_interceptors.js around onReceiveStatus's callback:

InterceptingListener.prototype.onReceiveStatus = function(status) {
  this._callNext('onReceiveStatus', [status]);
};

. . .

        response.metadata =
          Metadata._fromCoreRepresentation(response.metadata);
        first_listener.onReceiveMetadata(response.metadata);
        first_listener.onReceiveMessage(deserialized);
        first_listener.onReceiveStatus(status);

and have no idea where the problem is.

suntong commented 3 years ago

More details, I've been using

export WECHATY_PUPPET_HOSTIE_ENDPOINT=114.215.83.32:7777

as instructed, but am getting:

{ Error: 16 UNAUTHENTICATED: {code:8,message:"A token(114.215.83.32:7777) must be prefixed with a 'puppet_rock_' "}

So I changed it to

export WECHATY_PUPPET_HOSTIE_ENDPOINT=puppet_rock_114.215.83.32:7777

I.e., I'm suspecting that the DNS resolution failed might have something to do with HOSTIE_ENDPOINT=puppet_rock_114.215.83.32:7777

suntong commented 3 years ago

The latest version doesn't need WECHATY_PUPPET_HOSTIE_ENDPOINT variable.

which version it is? Mine is wechaty-puppet-hostie@0.11.10 and npm outdated is not listing wechaty-puppet-hostie, yet, this is what I'm getting if not setting WECHATY_PUPPET_HOSTIE_ENDPOINT variable:

$ node ding-dong-bot.js
14:03:27 ERR PuppetHostie start() rejection: no endpoint
Error: no endpoint
    at PuppetHostie.<anonymous> (/.../node_modules/wechaty-puppet-hostie/dist/src/client/puppet-hostie.js:69:31)
suntong commented 3 years ago

OK. I redid the installation from scratch.

rm -rf package*.json node_modules/
npm init -y
npm install wechaty@next

and now I have a super clean package.json file:

$ jq .dependencies package.json
{
  "wechaty": "^0.51.8"
}

and concise installed packages:

└─┬ wechaty@0.51.8
  ├─┬ wechaty-puppet@0.33.6
  │ ├─┬ file-box@0.16.4
  ├─┬ wechaty-puppet-hostie@0.11.10

Indeed WECHATY_PUPPET_HOSTIE_ENDPOINT is no longer necessary, but I'm still getting the above reported error:

unset WECHATY_PUPPET_HOSTIE_ENDPOINT

$ node ding-dong-bot.js
23:24:46 ERR PuppetHostie start() rejection: 16 UNAUTHENTICATED: {code:8,message:"A token(114.215.83.32:7777) must be prefixed with a 'puppet_rock_' "}
{ Error: 16 UNAUTHENTICATED: {code:8,message:"A token(114.215.83.32:7777) must be prefixed with a 'puppet_rock_' "}
    at Object.exports.createStatusError (/.../node_modules/grpc/src/common.js:91:15)
. . .
huan commented 3 years ago

{ Error: 16 UNAUTHENTICATED: {code:8,message:"A token(114.215.83.32:7777) must be prefixed with a 'puppetrock' "}

The above log message is telling you that your token format is not right.

You need to add the prefix puppet_rock_ to your token and try again.

suntong commented 3 years ago

The above log message is telling you that your token format is not right.

Note that it complains about the token 114.215.83.32:7777, which is the IP of the WECHATY_PUPPET_HOSTIE_ENDPOINT, which is I don't need to set any more.

You need to add the prefix puppet_rock_ to your token and try again.

I've tried both, with and without prefix puppet_rock_ to my token, and the result is exactly the same, which makes me believe that it is the WECHATY_PUPPET_HOSTIE_ENDPOINT's internal problem.

@huan / @jcai, if it is working in your environment, please at least let me know what versions of your packages, and what exactly environment variables you have set to make it working. Thx.

huan commented 3 years ago

@suntong can you get the IP and port information from the https://api.chatie.io/v0/hosties/YOUR_TOKEN ?

huan commented 3 years ago

And I agree that the below error message is confusing:

A token(114.215.83.32:7777) must be prefixed with a 'puppetrock'

Ip should not be prefixed, I guess it should be the token that user provided? @jcai

suntong commented 3 years ago

image

King-Red commented 2 years ago

请问这个问题解决了吗?怎么解决的?

suntong commented 2 years ago

If I've solved it, I'd have closed it.

Please report what you're experiencing @King-Red, things might be quite different two years later.