wechaty-puppet-padplus icon indicating copy to clipboard operation
wechaty-puppet-padplus copied to clipboard

padplus 异常重新登录

Open xiaogan18 opened this issue 5 years ago • 19 comments

异常

PuppetPadplus 掉线重新登录

logs

17:39:36 WARN Puppet constructor() watchdog.on(reset) reason: {"data":"ea2084d9-82c9-445f-a1bc-c2ca2e90f3d2","timeout":60000}
17:39:36 INFO PuppetPadplus stop()
17:39:36 INFO PuppetPadplus logout(true, logout in wechaty)
17:39:36 INFO Contact logout
17:39:41 INFO PuppetPadplus start()
17:47:28 ERR PadplusUser can not get callback result of INIT
17:47:34 INFO Contact login

xiaogan18 avatar Jun 16 '20 10:06 xiaogan18

已经是第二次出现,并且重新上线后会获取到很久以前的微信消息,是否有什么办法过滤这些旧消息?

xiaogan18 avatar Jun 16 '20 10:06 xiaogan18

The Message class has a method named age(), which can tell you the age of this message.

You can try to filter out the messages based on their age.

huan avatar Jun 16 '20 10:06 huan

what's the unit of age(),I realize this function return as a number

xiaogan18 avatar Jun 16 '20 11:06 xiaogan18

Please see the related code: it's the number of seconds since the message was born.

huan avatar Jun 16 '20 11:06 huan

OK. So why this situation happened, I must keep stability of my WeChat bot, but this situation is fatal.

xiaogan18 avatar Jun 16 '20 11:06 xiaogan18

Happened again today morning, logs below :

09:03:17 ERR GRPC_GATEWAY ApiType: SEND_MESSAGE request timeout, traceId: e182bd2f-0c5e-4ab7-babd-424d3da5a9f1
(node:27090) UnhandledPromiseRejectionWarning: Error: can not send message due to this error: Error: can not get response from grpc server
    at PadplusMessage.<anonymous> (/home/ubuntu/.repe/repe_bot/node_modules/wechaty-puppet-padplus/dist/src/padplus-manager/api-request/message.js:180:23)
    at Generator.next (<anonymous>)
    at fulfilled (/home/ubuntu/.repe/repe_bot/node_modules/wechaty-puppet-padplus/dist/src/padplus-manager/api-request/message.js:5:58)
(node:27090) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2187)

If wechaty do any scheme for the service high available ? It's very important.

xiaogan18 avatar Jun 30 '20 01:06 xiaogan18

looks like happened only when the GRPC server is encountering high traffic. realted to: #267 and #272 .

Unless scanning qr code and re-logging-in can be automated, I don't see any way around this problem except for running your own GRPC server and reverse engeering a similiar padplus protocol on a jailbroken ipad (or a ipad simulator? not 100% sure how it's actually implemented but you get the idea: lots of tinkering better to leave to a vc-funded start-up =) ).

or maybe implement a fall-back server and use the 群机器人 by 企业微信 to forward the qr-code to your wechat.

archywillhe avatar Jul 05 '20 05:07 archywillhe

@xiaogan18 I just noticed your timeout error is different from the one i mentioned above; yours is created at line 52 of message.ts inside sendMessage

  public async sendMessage (
    selfId: string,
    receiverId: string,
    content: string,
    messageType: PadplusMessageType,
    mentionListStr?: string,
  ): Promise<GrpcResponseMessageData> {
    log.verbose(PRE, `sendMessage()`)

    const data = {
      content: content,
      fromUserName: selfId,
      mentionListStr,
      messageType,
      toUserName: receiverId,
    }

    try {
      const result = await this.requestClient.request({
        apiType: ApiType.SEND_MESSAGE,
        data,
      })
....

Looks like something wrong with your requestClient.request.

Not 100% the same as mine but i think hv to do with the grpc server being busy too.

archywillhe avatar Jul 05 '20 06:07 archywillhe

Is there any solution or how can it deploy my own GRPC service?

xiaogan18 avatar Jul 06 '20 01:07 xiaogan18

I have the same issue today, see logs

16:28:21 INFO PuppetPadplus start()
16:28:22 INFO StarterBot Contact<小助手> login
16:28:22 INFO PuppetPadplus logout(true, 实例不存在)
16:28:22 INFO StarterBot Contact<小助手> logout
16:28:22 INFO PuppetPadplus stop()
16:28:22 INFO PuppetPadplus logout(true, logout in wechaty)
16:28:27 INFO PuppetPadplus start()
16:28:29 INFO StarterBot Contact<小助手> login
16:28:29 INFO PuppetPadplus logout(true, 实例不存在)
16:28:29 INFO StarterBot Contact<小助手> logout
16:28:29 INFO PuppetPadplus stop()
16:28:29 INFO PuppetPadplus logout(true, logout in wechaty)
16:28:34 INFO PuppetPadplus start()
16:28:35 INFO StarterBot Contact<小助手> login
16:28:35 INFO PuppetPadplus logout(true, 实例不存在)
16:28:35 INFO StarterBot Contact<小助手> logout
16:28:35 INFO PuppetPadplus stop()
16:28:35 INFO PuppetPadplus logout(true, logout in wechaty)
16:28:40 INFO PuppetPadplus start()
16:28:41 INFO StarterBot Contact<小助手> login
16:28:42 INFO PuppetPadplus logout(true, 实例不存在)
16:28:42 INFO StarterBot Contact<小助手> logout
16:28:42 INFO PuppetPadplus stop()
16:28:42 INFO PuppetPadplus logout(true, logout in wechaty)
16:28:47 INFO PuppetPadplus start()
....

My bot is dead now...

treeguard avatar Jul 26 '20 23:07 treeguard

@treeguard Could you please delete the xxx-memory-card.json file in your project. And restart to get QR code.

su-chang avatar Jul 27 '20 14:07 su-chang

Recently, bot logout automatic almost every day, logs below:

00:44:05 ERR GRPC_GATEWAY ApiType: HEARTBEAT request timeout, traceId: cd5e7f63-a71d-4d5b-ab97-b3f1928f651e
00:44:05 ERR GRPC_GATEWAY can not get heartbeat from grpc server
03:09:31 INFO PuppetPadplus logout(true, 你的微信登录环境存在异常。为了帐号安全,本次登录已失效。)
03:09:31 INFO Contact<repe-cpp> logout
03:09:31 INFO PuppetPadplus stop()
03:09:31 INFO PuppetPadplus logout(true, logout in wechaty)

xiaogan18 avatar Aug 12 '20 10:08 xiaogan18

03:09:31 INFO PuppetPadplus logout(true, 你的微信登录环境存在异常。为了帐号安全,本次登录已失效。)

It seems that your WeChat account is under the official risk management, please make sure you have already set name for your wechaty bot, it will generate xxx.memory-card.json automatically, you can regard it as your account session.

BTW, please pay attention to the actions about your bot.

su-chang avatar Aug 12 '20 10:08 su-chang

03:09:31 INFO PuppetPadplus logout(true, 你的微信登录环境存在异常。为了帐号安全,本次登录已失效。)

It seems that your WeChat account is under the official risk management, please make sure you have already set name for your wechaty bot, it will generate xxx.memory-card.json automatically, you can regard it as your account session.

BTW, please pay attention to the actions about your bot.

How to set name for my bot, and where is the file xxx.memory-card.json?

xiaogan18 avatar Aug 13 '20 01:08 xiaogan18

How to set name for my bot, and where is the file xxx.memory-card.json?

See here

su-chang avatar Aug 13 '20 01:08 su-chang

or maybe implement a fall-back server and use the 群机器人 by 企业微信 to forward the qr-code to your wechat.

I actually ended up writing a wechaty plugin for that! =)) https://github.com/archywillhe/wechaty-log-monitor

@xiaogan18 on side note I think it will help if real-name verification is done on the wechat account, and another thing you can do to ensure stability is to just voluntariarly log out & log in everyday in the morning (or at night before sleep, etc) and make that into a part of your devops routine.

archywillhe avatar Aug 13 '20 11:08 archywillhe

I did this:

const botName="repe-cpp"
var bot = {}
async function init() {
  var BOT_CONFIG = await apis.getToken()

  const puppet = new PuppetPadplus({
    token: BOT_CONFIG.token,
  })

  bot = new Wechaty({
    puppet,
    botName,
  })
  bot.on('scan', onScan) //扫码触发
  bot.on('login', onLogin) //登录成功
  bot.on('logout', onLogout) //登出
  bot.on('message', onMessage) //收到消息
  bot.on('friendship', onFriendship) //新联系人 
  bot.on('room-join', onOneJoinRoom) //新人加入群聊
  bot.on('room-invite', onRoomInvite) //邀请加入群聊

  bot.start()
    .then(onStart)
    .catch(e => console.error(e))
}

Still:

03:16:28 INFO PuppetPadplus logout(true, 你的微信登录环境存在异常。为了帐号安全,本次登录已失效。)
03:16:28 INFO Contact<repe-cpp> logout
03:16:28 INFO PuppetPadplus stop()
03:16:28 INFO PuppetPadplus logout(true, logout in wechaty)

And I can't find xxx.memory-card.json anywhere

xiaogan18 avatar Aug 14 '20 02:08 xiaogan18

  bot = new Wechaty({
    puppet,
    botName,
  })

Please set name rather than botName for Wechaty, so you should change it to:

bot = new Wechaty({
    puppet,
    name: botName,
})

su-chang avatar Aug 14 '20 03:08 su-chang

I did this, and I got the file xxx.memory-card.json, still...

xiaogan18 avatar Aug 18 '20 01:08 xiaogan18