Closed ith5cn closed 5 months ago
报错看是你本地的缓存文件被占用了,看看是不是启动了多个bot
报错看是你本地的缓存文件被占用了,看看是不是启动了多个bot
嗯。怎么查看,是否启动多个bot. 目前我已经把机器重启后,重新运行代码,依然不行。
我尝试脱离框架,用纯js写了端代码。您看下。应该代码层面,就启动了一次.
app.js
import { ScanStatus, WechatyBuilder } from "@juzi/wechaty";
import PuppetService from "@juzi/wechaty-puppet-service";
import QrcodeTerminl from 'qrcode-terminal'
main()
function main(){
const puppet = new PuppetService({
token: 'puppet_workpro_xxxxxxx',
authority: 'token-service-discovery-test.juzibot.com',
timeoutSeconds: 1 * 60,
tls: {
disable: true
}
})
const bot = WechatyBuilder.build({
puppet
})
bot
.on('scan', async (qrcode, status) => {
if (status === ScanStatus.Waiting) {
QrcodeTerminl.generate(qrcode, {
small: true
})
}
})
.on('verify-code', (id, message, scene, status) => {
console.log('verify-code', id, message, scene, status)
})
.on('login', async user => {
console.log(JSON.stringify(user.payload))
console.log(`
============================================
user: ${JSON.stringify(user)}, friend: ${user.friend()}, ${user.coworker()}
============================================
`)
// console.log(await bot.Wecom.getExternalUserId(
// ['7881300890159037'],
// ))
})
bot.start()
}
下面是我的package.json配置
"scripts": {
"start": "cross-env WECHATY_PUPPET_SERVICE_AUTHORITY=token-service-discovery-test.juzibot.com nodemon --exec 'babel-node ./app.js'"
},
"dependencies": {
"@juzi/wechaty": "^1.0.99",
"@juzi/wechaty-puppet-service": "^1.0.97",
"qrcode-terminal": "^0.12.0"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.7",
"@babel/node": "^7.22.19",
"@babel/plugin-transform-modules-systemjs": "^7.23.3",
"@babel/preset-env": "^7.23.8",
"nodemon": "^3.0.3"
}
遇到的报错如下
maiyongchao@maiyongchaodeMacBook-Pro wechaty-demo % npm run start
> wechaty-demo@1.0.0 start
> cross-env WECHATY_PUPPET_SERVICE_AUTHORITY=token-service-discovery-test.juzibot.com nodemon --exec 'babel-node ./app.js'
[nodemon] 3.1.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `babel-node ./app.js`
15:05:10 INFO PuppetSkeleton start()
15:05:10 INFO PuppetService start() instanciating GrpcManager ...
15:05:10 INFO PuppetService start() instanciating GrpcManager ... done
15:05:10 INFO PuppetService start() setting up bridge grpc event stream ...
15:05:10 INFO PuppetService start() setting up bridge grpc event stream ... done
15:05:10 INFO PuppetService start() starting grpc manager...
15:05:10 WARN last event was 1717571110.259 seconds ago, will not request event cache
15:05:10 WARN GrpcManager initClient() TLS: disabled (INSECURE)
15:05:10 INFO GrpcManager startStream() connecting event stream with account undefined and seq undefined
/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/subchannel-address.js:22
return 'port' in address;
^
TypeError: Cannot use 'in' operator to search for 'port' in undefined
at isTcpSubchannelAddress (/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/subchannel-address.js:22:19)
at interleaveAddressFamilies (/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/load-balancer-pick-first.js:107:71)
at PickFirstLoadBalancer.updateAddressList (/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/load-balancer-pick-first.js:419:29)
at ChildLoadBalancerHandler.updateAddressList (/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/load-balancer-child-handler.js:115:23)
at onSuccessfulResolution (/Users/maiyongchao/code/wechaty-demo/node_modules/@grpc/grpc-js/build/src/resolving-load-balancer.js:221:40)
at process.processTicksAndRejections (node:internal/process/task_queues:85:22)
Node.js v18.19.1
[nodemon] app crashed - waiting for file changes before starting...
下面是我token的状态
嗯你第二次启动就是另一个地方抛错了。anyway 解决了就好。
嗯你第二次启动就是另一个地方抛错了。anyway 解决了就好。
已经解决了。thanks, 强大的Issuse
"@juzi/wechaty": "^1.0.99", "@juzi/wechaty-puppet-service": "^1.0.97", "qrcode-terminal": "^0.12.0",
在配置完成后,bot.start(),出错。
10:58:49 INFO PuppetSkeleton start() 10:58:49 INFO PuppetService start() instanciating GrpcManager ... 10:58:49 INFO PuppetService start() instanciating GrpcManager ... done 10:58:49 INFO PuppetService start() setting up bridge grpc event stream ... 10:58:49 INFO PuppetService start() setting up bridge grpc event stream ... done 10:58:49 INFO PuppetService start() starting grpc manager...
/Users/maiyongchao/code/wechaty-bot/node_modules/deferred-leveldown/deferred-leveldown.js:49 return callback(err || new Error('Database is not open')) ^ OpenError: IO error: lock /Users/maiyongchao/.wechaty/wechaty-puppet-service/puppet_workpro_465b95bb74f64c36aeaa0ae0e8c19b81/v1.0/miscellaneous/LOCK: already held by process at /Users/maiyongchao/code/wechaty-bot/node_modules/levelup/lib/levelup.js:127:23 at /Users/maiyongchao/code/wechaty-bot/node_modules/abstract-leveldown/abstract-leveldown.js:41:14 at onopen (/Users/maiyongchao/code/wechaty-bot/node_modules/deferred-leveldown/deferred-leveldown.js:49:14) at /Users/maiyongchao/code/wechaty-bot/node_modules/abstract-leveldown/abstract-leveldown.js:41:14 at /Users/maiyongchao/code/wechaty-bot/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
尝试解决: