wechaty / puppet-service

Wechaty Puppet Provider for providing/consuming the Wechaty Puppet Service
https://paka.dev/npm/wechaty-puppet-service
Apache License 2.0
74 stars 18 forks source link

ERR PuppetHostie start() rejection: 14 UNAVAILABLE: failed to connect to all addresses #114

Open suntong opened 3 years ago

suntong commented 3 years ago

I always get ERR PuppetHostie start() rejection: 14 UNAVAILABLE: failed to connect to all addresses on my server, yet on my own machine, same-everything works just fine.

More Info/Details ``` $ WECHATY_LOG=silly node ding-dong-bot.js 23:31:52 SILL Config WECHATY_LOG set level to silly 23:31:52 INFO Config registering process.on("unhandledRejection") for development/debug 23:31:52 VERB Config constructor() 23:31:53 VERB Wechaty contructor() 23:31:53 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 23:31:53 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 23:31:53 VERB Wechaty on(scan, function) registered 23:31:53 VERB Wechaty addListenerFunction(scan) 23:31:53 VERB Wechaty on(login, function) registered 23:31:53 VERB Wechaty addListenerFunction(login) 23:31:53 VERB Wechaty on(logout, function) registered 23:31:53 VERB Wechaty addListenerFunction(logout) 23:31:53 VERB Wechaty on(message, function) registered 23:31:53 VERB Wechaty addListenerFunction(message) 23:31:53 INFO Wechaty (ding-dong-bot) start() v0.38.4 is starting... 23:31:53 VERB Wechaty id: cki...obh 23:31:53 SILL StateSwitch on() is false 23:31:53 SILL StateSwitch off() is true 23:31:53 VERB StateSwitch off(true) <- (true) 23:31:53 SILL StateSwitch on() is false 23:31:53 VERB StateSwitch on(pending) <- (false) 23:31:53 VERB MemoryCard constructor("ding-dong-bot") 23:31:53 VERB MemoryCard getStorage() for storage type: N/A 23:31:53 VERB getStorage name: ding-dong-bot, options: {"type":"file"} 23:31:53 VERB StorageFile constructor(ding-dong-bot, ...) 23:31:53 VERB StorageBackend constructor(ding-dong-bot, { type: file }) 23:31:53 VERB MemoryCard load() from storage: StorageFile 23:31:53 VERB StorageFile load() from /path/to/ding-dong-bot.memory-card.json 23:31:53 VERB MemoryCard load() file not exist, NOOP 23:31:53 VERB Wechaty initPuppet() 23:31:53 VERB MemoryCard multiplex(puppet) 23:31:53 VERB MemoryCard static multiplex(MemoryCard, puppet) 23:31: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"}}}}) 23:31:53 VERB PuppetManager resolve({puppet: wechaty-puppet-hostie, puppetOptions: undefined}) 23:31:53 VERB PuppetManager resolveName(wechaty-puppet-hostie) 23:31:53 VERB PuppetManager checkModule(wechaty-puppet-hostie) 23:31:53 SILL PuppetManager checkModule() wechaty-puppet-hostie installed version 0.6.1 satisfied range ^0.6.1 23:31:53 VERB Puppet constructor({}) #0 23:31:53 VERB StateSwitch constructor(PuppetHostie, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}") 23:31:53 VERB MemoryCard constructor(undefined) 23:31:53 VERB MemoryCard getStorage() for storage type: N/A 23:31:53 VERB MemoryCard load() from storage: N/A 23:31:53 VERB MemoryCard load() no storage 23:31:53 VERB Puppet constructor() watchdog timeout set to 60 seconds 23:31:53 VERB HotImport callerResolve(., /path/to/node_modules/wechaty-puppet/dist/src/puppet.js) 23:31:53 SILL HotImport callerResolve() callsites() file=/path/to/node_modules/hot-import/dist/src/hot-import.js, type=Object 23:31:53 SILL HotImport callerResolve() callsites() file=/path/to/node_modules/wechaty-puppet/dist/src/puppet.js, type=null 23:31:53 SILL HotImport callerResolve() callsites() file=/path/to/node_modules/wechaty-puppet-hostie/dist/src/client/puppet-hostie.js, type=null 23:31:53 SILL HotImport callerResolve() callerFile=/path/to/node_modules/wechaty-puppet-hostie/dist/src/client/puppet-hostie.js 23:31:53 VERB Puppet constructor() childClassPath=/path/to/node_modules/wechaty-puppet-hostie/dist/src/client 23:31:53 VERB Puppet constructor() memory.load() done 23:31:53 VERB Puppet setMemory() 23:31:53 VERB Wechaty initPuppetEventBridge(Puppet#0(ding-dong-bot)) 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(login) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(logout) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(message) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(scan) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(dong) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(error) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(heartbeat) (listenerCount:1) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(ready) (listenerCount:0) registering... 23:31:53 VERB Wechaty initPuppetEventBridge() puppet.on(reset) (listenerCount:1) registering... 23:31:53 VERB Wechaty initAccessory(Puppet#0(ding-dong-bot)) 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set wechaty = "Wechaty#cki6wydw300004hh3bezjgobh<>(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 SILL Accessory static set puppet = "Puppet#0(ding-dong-bot)" 23:31:53 VERB PuppetHostie start() 23:31:53 SILL StateSwitch on() is false 23:31:53 SILL StateSwitch on() is false 23:31:53 VERB StateSwitch on(pending) <- (false) 23:31:53 VERB PuppetHostie startGrpcClient() 23:31:53 VERB PuppetHostie discoverHostieIp(puppet_donut_37...56d) 23:31:53 VERB PuppetHostie discoverHostieIp() 161.189.225.62 23:31:53 VERB PuppetHostie startGrpcStream() 23:31:53 ERR PuppetHostie start() rejection: 14 UNAVAILABLE: failed to connect to all addresses 23:31:53 SILL StateSwitch off() is false 23:31:53 VERB StateSwitch off(true) <- (false) { Error: 14 UNAVAILABLE: failed to connect to all addresses at Object.exports.createStatusError (/path/to/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/path/to/node_modules/grpc/src/client_interceptors.js:1209:28) at InterceptingListener._callNext (/path/to/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/path/to/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/path/to/node_modules/grpc/src/client_interceptors.js:847:24) code: 14, metadata: Metadata { _internal_repr: {}, flags: 0 }, details: 'failed to connect to all addresses' } 23:31:53 ERR Wechaty start() exception: 14 UNAVAILABLE: failed to connect to all addresses 23:31:53 ERR StarterBot Error: 14 UNAVAILABLE: failed to connect to all addresses 23:31:53 VERB PuppetHostie startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: failed to connect to all addresses 23:31:53 SILL Puppet constructor() this.on(reset) payload: "{"data":"startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: failed to connect to all addresses"}" 23:31:53 SILL Puppet constructor() resetThrottleQueue.subscribe() reason: "startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: failed to connect to all addresses" 23:31:53 VERB Puppet reset(startGrpcStream() eventStream.on(error) Error: 14 UNAVAILABLE: failed to connect to all addresses) 23:31:53 VERB PuppetHostie stop() 23:31:53 SILL StateSwitch off() is true 23:31:53 WARN PuppetHostie stop() is called on a OFF puppet. await ready(off) and return. 23:31:53 VERB StateSwitch ready(off, false) 23:31:53 SILL StateSwitch ready(off, false) resolved. 23:31:53 VERB PuppetHostie start() 23:31:53 SILL StateSwitch on() is false 23:31:53 SILL StateSwitch on() is false 23:31:53 VERB StateSwitch on(pending) <- (false) 23:31:53 VERB PuppetHostie startGrpcClient() 23:31:53 ERR PuppetHostie start() rejection: puppetClient had already inited 23:31:53 SILL StateSwitch off() is false 23:31:53 VERB StateSwitch off(true) <- (false) 23:31:53 WARN Puppet reset() exception: Error: puppetClient had already inited 23:31:53 ERR Config ########################### 23:31:53 ERR Config unhandledRejection: Error [object Promise] 23:31:53 ERR Config ########################### 23:31:53 ERR Config process.on(unhandledRejection) promise.catch() Config Error at PuppetHostie.puppet.on.payload (/path/to/node_modules/wechaty/dist/src/wechaty.js:433:44) at PuppetHostie.emit (events.js:198:13) at PuppetHostie.EventEmitter.emit (domain.js:448:20) at PuppetHostie.emit (/path/to/node_modules/wechaty-puppet/dist/src/puppet.js:162:22) at Promise.resolve.then.then.catch.e (/path/to/node_modules/wechaty-puppet/dist/src/puppet.js:191:18) at process._tickCallback (internal/process/next_tick.js:68:7) (node:35153) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3) ```

ding-dong-bot.js is just the standard example from wechaty-getting-started.

Please double-check. Thanks. 

Oh, not same everything. I did installation/upgrade later on my server than on my own machine, but within two days. why the versions are so different:

on my server:

$ npm ls wechaty wechaty-puppet wechaty-puppet-mock wechaty-puppet-padplus wechaty-puppet-puppeteer wechaty-puppet-hostie
+-- wechaty@0.51.5 
| +-- wechaty-puppet@0.33.6 
| `-- wechaty-puppet-hostie@0.11.10 
+-- UNMET PEER DEPENDENCY wechaty-puppet@0.32.3 
+-- wechaty-puppet-hostie@0.10.8 
+-- wechaty-puppet-mock@0.28.1 
`-- wechaty-puppet-puppeteer@0.22.1 
huan commented 3 years ago

A tip: The Wechaty has already depemdencied the wechaty-puppet and wechaty-puppet-hostie internally so they can be safely removed from your package.json.

suntong commented 3 years ago

Good to know. thx.

I tried again today, from scratch and got the exact same error as above:

rm -rf node_modules/
npm install wechaty@next

$ npm ls | grep -E 'wechaty|file-box'
wechaty-getting-started@0.1.20 /sysvol/gt/nodejs/step1/wechaty-examples
+-- file-box@0.14.3
+-- wechaty@0.51.5
| +-- wechaty-puppet@0.33.6
| | +-- file-box@0.16.4
| +-- 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
node ding-dong-bot.js
19:42:49 INFO Wechaty <wechaty-puppet-hostie>(ding-dong-bot) start() v0.38.4 is starting...
19:42:49 ERR PuppetHostie start() rejection: 14 UNAVAILABLE: failed to connect to all addresses
{ Error: 14 UNAVAILABLE: failed to connect to all addresses
. . .
suntong commented 3 years ago

checked with my own machine and just realized that they are the same version. So looking closely at the log again,

23:31:53 VERB PuppetHostie startGrpcClient()
23:31:53 VERB PuppetHostie discoverHostieIp(puppet_donut_37...6d)
23:31:53 VERB PuppetHostie discoverHostieIp() 161.189.225.62
23:31:53 VERB PuppetHostie startGrpcStream()
23:31:53 ERR PuppetHostie start() rejection: 14 UNAVAILABLE: failed to connect to all addresses

It fails right after trying to make Grpc Stream connection to HostieIp 161.189.225.62. What kind of connection is that? -- The only difference between my machine and my server is that my Azure server might be blocking some ports by default. So,

Is there any ports that I need to open before using wechaty-puppet-hostie?

huan commented 3 years ago

rm -rf node_modules/

This is not enough. You need to remove the dependencies from your package.json.

What kind of connection is that?

As you said, that's a gRPC connection

Is there any ports that I need to open before using wechaty-puppet-hostie?

Of course! I'd like to suggest that you open all ports to have a test. If it works after open all ports (disable the network firewall), then means they are related.

suntong commented 3 years ago

The Azure server's port need to be opened one by one, one port per command.

suntong commented 3 years ago

The Azure server's port need to be opened one by one, one port per command.

No, it is not port's problem -- Found it is port# 14363 that 161.189.225.62 is using from my own machine. and connecting to it is not blocked on my server.

from my own machine

$ netstat -natup | grep 161.189.225.62
tcp        0      0 192.168.0.101:47728     161.189.225.62:14363    ESTABLISHED 3879501/node        

on my server

$ telnet -4 161.189.225.62 14363
Trying 161.189.225.62...
Connected to 161.189.225.62.
Escape character is '^]'.
@@ ?

$ nc -w3 -4 -v 161.189.225.62 14363
Connection to 161.189.225.62 14363 port [tcp/*] succeeded!
@@ ?
huan commented 3 years ago

Yes, if you only need an outgoing connection, the firewall will permit.

BTW: you can use the Azure web portal to open all the ports by one rule, as the following screenshot demonstrated: set the port to Any

image

suntong commented 3 years ago

you can use the Azure web portal to open all the ports by one rule

Oh, thx, will try...

This is not enough. You need to remove the dependencies from your package.json.

Oh, then seems that https://github.com/wechaty/wechaty-getting-started/blob/master/package.json is outdated as well. Can you change to what should be look like so that we can follow suite please?