juzibot / wxwork-tester-deprecated

35 stars 6 forks source link

启动报错 #58

Open upbot-doc opened 2 years ago

upbot-doc commented 2 years ago

代码:

import {
  ScanStatus,
  WechatyBuilder,
}                  from 'wechaty'
import QrcodeTerminal from 'qrcode-terminal';
const token = 'puppet_wxwork_xxxxxx'

const bot = WechatyBuilder.build({
  puppet: 'wechaty-puppet-service',
  puppetOptions: {
    token,
  }
});

bot
  .on('scan', (qrcode, status) => {
    if (status === ScanStatus.Waiting) {
      QrcodeTerminal.generate(qrcode, {
        small: true
      })
    }
  })
  .on('login', async user => {
    console.log(`user: ${JSON.stringify(user)}`)
  })
  .on('message', async message => {
    console.log(`message: ${JSON.stringify(message)}`)
  })
  .start()

启动报错:

Error: write EPROTO 140323733780416:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
  errno: -71,
  code: 'EPROTO',
  syscall: 'write'
}
11:40:44 WARN WechatyToken discover() retry.execute(discoverApi) fail: WechatyToken discover() endpoint<https://api.chatie.io/v0/hosties/puppet_wxwork_xxxxxx> rejection: Error: write EPROTO 140323733780416:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

11:40:44 WARN ResolverWechaty updateResolution() address not found target wechaty://api.chatie.io/puppet_wxwork_xxxxxx: token does not exist
node:events:504
      throw er; // Unhandled 'error' event
      ^

GError: 14 UNAVAILABLE: Wechaty service discovery / resolution failed for target wechaty://api.chatie.io/puppet_wxwork_xxxxxx: token "puppet_wxwork_xxxxxx" does not exist
    at Object.callErrorFromStatus (/data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/client.js:349:49)
    at Object.onReceiveStatus (/data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
    at /data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/call-stream.js:187:78
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
Emitted 'error' event on WechatyImpl instance at:
    at WechatyImpl.emit (file:///data/workspace/wechaty/wechaty-getting-started/node_modules/wechaty/dist/esm/src/wechaty-mixins/gerror-mixin.js:45:26)
    at PuppetService.<anonymous> (file:///data/workspace/wechaty/wechaty-getting-started/node_modules/wechaty/dist/esm/src/wechaty-mixins/puppet-mixin.js:155:34)
    at PuppetService.emit (node:events:526:28)
    at PuppetService.emit (file:///data/workspace/wechaty/wechaty-getting-started/node_modules/wechaty-puppet/dist/esm/src/puppet/puppet-skeleton.js:107:22)
    at GrpcManager.<anonymous> (file:///data/workspace/wechaty/wechaty-getting-started/node_modules/wechaty-puppet-service/dist/esm/src/client/puppet-service.js:162:18)
    at GrpcManager.emit (node:events:526:28)
    at ClientReadableStreamImpl.<anonymous> (file:///data/workspace/wechaty/wechaty-getting-started/node_modules/wechaty-puppet-service/dist/esm/src/client/grpc-manager.js:308:44)
    at ClientReadableStreamImpl.emit (node:events:538:35)
    at Object.onReceiveStatus (/data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/client.js:349:28)
    at Object.onReceiveStatus (/data/workspace/wechaty/wechaty-getting-started/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181) {
  code: 14,
  details: 'Wechaty service discovery / resolution failed for target wechaty://api.chatie.io/puppet_wxwork_xxxxxx: token "puppet_wxwork_xxxxxx" does not exist'
}
upbot-doc commented 2 years ago

token通过https://api.chatie.io/v0/hosties/xxx 验证是有效的

su-chang commented 2 years ago

如果使用的是wechaty@1.x版本,需要增加环境变量配置: WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=true

示例

WECHATY_LOG=verbose \
WECHATY_PUPPET=wechaty-puppet-service \
WECHATY_PUPPET_SERVICE_TOKEN=puppet_wxwork_xxxxx \
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=true \
npm start