小程序 websocket 关闭失败
👉 js ( 项目里的不行,我提出来了个简单的小 demo )
open () { this .socketTask = wx.connectSocket({ url: `ws: //xxx.xxx.xxx:xxxxx`, success: res => { console.log( '----- socket create -----' ) } }) this .socketTask.onOpen(onOpen => { // this._socketOpen = true console.log( '----- socket 连接打开 -----' ) }) this .socketTask.onClose(res => { console.log( 'res--------------------> ' , res) }) }, close () { this .socketTask.close() } |
👉 wxml
< button bindtap = "open" >打开</ button > < button bindtap = "close" >关闭</ button > |
👉 打印信息
👉!!!正常的关闭应该是 code 为 1000,但是我就是正常关闭,监控却是 1006 非正常关闭,求指导~~
2 回复
麻烦提供一下出现问题的机型和微信版本,并且给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)