Open xiaogan18 opened 4 years ago
已经是第二次出现,并且重新上线后会获取到很久以前的微信消息,是否有什么办法过滤这些旧消息?
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.
what's the unit of age()
,I realize this function return as a number
Please see the related code: it's the number of seconds since the message was born.
OK. So why this situation happened, I must keep stability of my WeChat bot, but this situation is fatal.
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.
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.
@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.
Is there any solution or how can it deploy my own GRPC service?
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 Could you please delete the xxx-memory-card.json file in your project. And restart to get QR code.
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)
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.
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 generatexxx.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
?
How to set name for my bot, and where is the file xxx.memory-card.json?
See here
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.
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
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,
})
I did this, and I got the file xxx.memory-card.json
, still...
异常
PuppetPadplus 掉线重新登录
logs