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

Unable to start multiple instances with padchat puppet #1367

Closed
IanSun opened this issue Jun 19, 2018 · 4 comments
Closed

Unable to start multiple instances with padchat puppet #1367

IanSun opened this issue Jun 19, 2018 · 4 comments

Comments

@IanSun
Copy link

IanSun commented Jun 19, 2018

Provide Your Network Information

  1. Where is the location of your server? (i.e. City, or In/Out China)
    In China

Run npm run doctor or wechaty run doctor(for docker user), paste output here

11:05:18 INFO Wechaty start() v0.15.211 is starting...
11:05:18 INFO Wechaty start() v0.15.211 is starting...
11:05:18 INFO Wechaty initPuppet() using puppet: padchat
11:05:18 INFO Wechaty initPuppet() using puppet: padchat
(node:1171) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'resolve' of undefined
    at Peer._callee$ (/usr/src/wechaty/node_modules/json-rpc-peer/dist/index.js:166:44)
    at tryCatch (/usr/src/wechaty/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/src/wechaty/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/src/wechaty/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/usr/src/wechaty/node_modules/@babel/runtime/helpers/asyncToGenerator.js:12:30)
    at _next (/usr/src/wechaty/node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:9)
    at /usr/src/wechaty/node_modules/@babel/runtime/helpers/asyncToGenerator.js:34:7
    at new Promise (<anonymous>)
    at new F (/usr/src/wechaty/node_modules/core-js/library/modules/_export.js:36:28)
    at Peer.<anonymous> (/usr/src/wechaty/node_modules/@babel/runtime/helpers/asyncToGenerator.js:7:12)
    at Peer.exec (/usr/src/wechaty/node_modules/json-rpc-peer/dist/index.js:198:20)
    at Peer.write (/usr/src/wechaty/node_modules/json-rpc-peer/dist/index.js:279:10)
    at PadchatManager.onSocketPadchat (/usr/src/wechaty/node_modules/wechaty/dist/src/puppet-padchat/padchat-rpc.js:349:22)
    at PadchatManager.onSocket (/usr/src/wechaty/node_modules/wechaty/dist/src/puppet-padchat/padchat-rpc.js:307:18)
    at WebSocket.ws.on (/usr/src/wechaty/node_modules/wechaty/dist/src/puppet-padchat/padchat-rpc.js:104:26)
    at WebSocket.emit (events.js:187:15)
    at WebSocket.EventEmitter.emit (domain.js:442:20)
    at Receiver.receiverOnMessage (/usr/src/wechaty/node_modules/ws/lib/websocket.js:718:20)
    at Receiver.emit (events.js:182:13)
    at Receiver.EventEmitter.emit (domain.js:442:20)
    at Receiver.dataMessage (/usr/src/wechaty/node_modules/ws/lib/receiver.js:414:14)
    at Receiver.getData (/usr/src/wechaty/node_modules/ws/lib/receiver.js:346:17)
    at Receiver.startLoop (/usr/src/wechaty/node_modules/ws/lib/receiver.js:133:22)
    at Receiver._write (/usr/src/wechaty/node_modules/ws/lib/receiver.js:69:10)
    at doWrite (_stream_writable.js:410:12)
    at writeOrBuffer (_stream_writable.js:394:5)
    at Receiver.Writable.write (_stream_writable.js:294:11)
    at Socket.socketOnData (/usr/src/wechaty/node_modules/ws/lib/websocket.js:788:35)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:442:20)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onread (net.js:635:20)
(node:1171) 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: 2)
(node:1171) [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.

Expected behavior

Multiple instances should be started.

Actual behavior

Only last instance was started, others were rejected by server.

@huan
Copy link
Member

huan commented Jun 19, 2018

Please check out the v0.15.213, and use the new puppetToken options for Wechaty.

Code example:

const girlBot = new Wechaty({
  profile: 'girl', 
  puppet: 'padchat',
  puppetToken: 'girl-token-for-puppet-padchat' 
})

const boyBot = new Wechaty({
  profile: 'boy', 
  puppet: 'padchat',
  puppetToken: 'boy-token-for-puppet-padchat' 
})

Please also noticed that you will need two padchat tokens to test this feature.

@huan
Copy link
Member

huan commented Jun 20, 2018

Update v0.15.216

const girlBot = new Wechaty({
  profile: 'girl', 
  puppet: 'padchat',
  puppetOptions: {
    token: 'girl-token-for-puppet-padchat' ,
  },
})

const boyBot = new Wechaty({
  profile: 'boy', 
  puppet: 'padchat',
  puppetOptions: {
    token: 'boy-token-for-puppet-padchat',
  },
})

@huan
Copy link
Member

huan commented Jun 21, 2018

Related to: #518

@huan
Copy link
Member

huan commented Jun 21, 2018

@YunSun-CN Thank you for closing this issue. 👍

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

No branches or pull requests

2 participants