Rocket1184 / qq-bot-rebown

[DEPRECATED!] SmartQQ robot written in JavaScript, using ES7 async/await features
https://web2.qq.com/
MIT License
56 stars 17 forks source link

msgContent errmsg 缺少错误处理 #13

Closed Zahariel1942 closed 6 years ago

Zahariel1942 commented 7 years ago

在程序执行一段时间后会接收到这样一条msg

msgContent
Object {errmsg: "error", retcode: -1}

msg不包含result[], 会引发logMessagehandelMsgRecv方法中

msg.result[0].value.content.filter  

undefined.

Zahariel1942 commented 7 years ago

这个pr并没有解决问题,程序仍会在运行一段时间之后持续报错。 需要找到真正可行的处理方法。

rocka commented 7 years ago

@nakating 经过一个星期的测试,发现 cookie 大概只能维持两天, 然后就会被强制下线。你说的持续报错应该是指的这个吧

{ errmsg: 'login error', retcode: 100001 }                     
Zahariel1942 commented 7 years ago

@Rocket1184 实际上不到2天,我测试运行几个小时就会出现一个{errmsg: "error", retcode: 0}的消息, 因为是0所以下面去尝试取result的时候就会异常。

rocka commented 7 years ago

index.js#L492-L493 有判断 result 是否存在,然后再去取里面的值了,这样还是不行么?

我也会收到这条消息,但并没有异常啊。。。

[Tue Oct 10 2017 18:16:56 GMT+0800 (CST)] DEBUG HTTP:
POST http://d1.web2.qq.com/channel/poll2
Status: 200 OK
Response Headers: {
  "date": "Tue, 10 Oct 2017 10:16:57 GMT",
  "content-type": "application/json; charset=utf-8",
  "content-length": "30",
  "connection": "close"
} 
Request Headers: {
  "Accept": "application/json, text/plain, */*",
  "Content-Type": "application/x-www-form-urlencoded",
  "Content-Length": 395,
  "Cookie": { ... },
  "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0",
  "Origin": "http://d1.web2.qq.com",
  "Referer": "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2"
}
[Tue Oct 10 2017 18:16:56 GMT+0800 (CST)] DEBUG { errmsg: 'error', retcode: 0 }
rocka commented 6 years ago

closed as work for me