Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

项目无法运行,代码报错如下 #65

Open
littlezyx opened this issue Aug 8, 2022 · 1 comment
Open

项目无法运行,代码报错如下 #65

littlezyx opened this issue Aug 8, 2022 · 1 comment

Comments

@littlezyx
Copy link

代码:
import {log, ScanStatus, WechatyBuilder} from "wechaty";
import {PuppetPadlocal} from "wechaty-puppet-padlocal";
import {PuppetService} from "wechaty-puppet-service";
import {dingDongBot, getMessagePayload, LOGPRE} from "./helper";

/****************************************

  • 去掉注释,可以完全打开调试日志
    ****************************************/
    // log.level("silly");

const puppet = new PuppetService({
token: "puppet_wxwork_6f2c0273cebc444a"
})

const bot = WechatyBuilder.build({
name: "PuppetServiceDemo",
puppet,
})
.on("scan", (qrcode, status) => {
if (status === ScanStatus.Waiting && qrcode) {
// const qrcodeImageUrl = [
// 'https://wechaty.js.org/qrcode/',
// encodeURIComponent(qrcode),
// ].join('')

  // log.info(LOGPRE, `onScan: ${ScanStatus[status]}(${status})`);

  // console.log("\n==================================================================");
  // console.log("\n* Two ways to sign on with qr code");
  // console.log("\n1. Scan following QR code:\n");

  require('qrcode-terminal').generate(qrcode, {small: true})  // show qrcode on console

  // console.log(`\n2. Or open the link in your browser: ${qrcodeImageUrl}`);
  console.log("\n==================================================================\n");
} else {
  log.info(LOGPRE, `onScan: ${ScanStatus[status]}(${status})`);
}

})

.on("login", (user) => {
log.info(LOGPRE, ${user} login);
})

.on("logout", (user, reason) => {
log.info(LOGPRE, ${user} logout, reason: ${reason});
})

.on("message", async (message) => {
log.info(LOGPRE, on message: ${message.toString()});

await getMessagePayload(message);

await dingDongBot(message);

})

.on("room-invite", async (roomInvitation) => {
log.info(LOGPRE, on room-invite: ${roomInvitation});
})

.on("room-join", (room, inviteeList, inviter, date) => {
log.info(LOGPRE, on room-join, room:${room}, inviteeList:${inviteeList}, inviter:${inviter}, date:${date});
})

.on("room-leave", (room, leaverList, remover, date) => {
log.info(LOGPRE, on room-leave, room:${room}, leaverList:${leaverList}, remover:${remover}, date:${date});
})

.on("room-topic", (room, newTopic, oldTopic, changer, date) => {
log.info(LOGPRE, on room-topic, room:${room}, newTopic:${newTopic}, oldTopic:${oldTopic}, changer:${changer}, date:${date});
})

.on("friendship", (friendship) => {
log.info(LOGPRE, on friendship: ${friendship});
})

.on("error", (error) => {
log.error(LOGPRE, on error: ${error});
})

bot.start().then(() => {
log.info(LOGPRE, "started.");
});
报错:
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
16:01:03 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established
16:01:03 WARN ServiceCtl stop() found that is starting...
16:01:03 WARN ServiceCtl stop() found that is starting, waiting stable ... (max 5 seconds)
16:01:08 ERR [PadLocalDemo] on error: DEADLINE_EXCEEDED: Timeout after 5000 ms
16:01:08 WARN ServiceCtl stop() found that is starting, waiting stable ... timeout
16:01:08 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established
16:01:08 ERR [PadLocalDemo] on error: Error: 14 UNAVAILABLE: No connection established
16:01:08 INFO [PadLocalDemo] started.

@hcfw007
Copy link
Member

hcfw007 commented Aug 8, 2022

const puppet = new PuppetService({
  token: "puppet_wxwork_6f2c0273cebc444a"
})

改为

const puppet = new PuppetService({
  tls: {
    disable: true
  },
  token: "puppet_wxwork_6f2c0273cebc444a"
})

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

No branches or pull requests

2 participants