sendSocketMessage: fail taskID not exist
[代码]//创建连接[代码] [代码]if[代码] [代码](![代码][代码]this[代码][代码]._socketTask || [代码][代码]this[代码][代码]._socketTask.readyState!=1) {[代码] [代码] this[代码][代码]._socketTask = wx.connectSocket({[代码][代码] url: option.url,[代码][代码] header: {[代码][代码] ...option.header,[代码][代码] 'content-type'[代码][代码]: [代码][代码]'application/json'[代码][代码] },[代码][代码] method: [代码][代码]'GET'[代码][代码],[代码][代码] fail: [代码][代码]function[代码][代码](res){[代码][代码] self._isLogin = [代码][代码]false[代码][代码] self.reConnect()[代码][代码] }[代码][代码] })[代码] [代码]}[代码][代码]sendHeartBreakMsg() {[代码][代码] [代码][代码]let self = [代码][代码]this[代码][代码] [代码][代码]try[代码][代码]{[代码] [代码] //wx.sendSocketMessage ({})使用sendSocketMessage 同样会出现[代码] [代码] [代码][代码]self._socketTask.send({[代码][代码] [代码][代码]data: [代码][代码]'HB_'[代码][代码]+wx.getStorageSync([代码][代码]'loginInfo'[代码][代码]).token,[代码][代码] [代码][代码]success: (e) => {[代码][代码] [代码][代码]// console.log('HB')[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: (res) => {[代码][代码] [代码][代码]console.log(res, self._socketTask, self._options, self._socketTask.readyState)[代码][代码] [代码][代码]if[代码] [代码](self._socketTask && self._socketTask.readyState != 1) {[代码][代码] [代码][代码]self.reConnect()[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码][代码](!self._socketTask) {[代码][代码] [代码][代码]self.createConnection()[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]catch[代码][代码](e){[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码]错误日志已上传2019-05-21 正常connectSocket创建连接,测试使用两种方法发送message:sendSocketMessage / socketTask.send 发送。
一切在3-5分钟内是好的。切到后台,回到微信连天页面,再切回小程序,消息还是正常发送。操作3-5分钟后,发送消息就会报 sendSocketMessage: fail 。taskID not exist。此时websocket是连通的,readystate是open状态。我就想问一下这个报错是什么意思?导致sendSocketMessage一直报错。只有关闭微信重开才可以解决。kill吊销程序重启才能解决。
手机:iphoneXr IOS 12.2 微信版本: 7.0.4 基础库版本:2.7.0 [图片] [图片]