- 微信小游戏无法使用Websocket
调用微信的websocket接口 返回 1006 "abnormal closure" 错误! 是自动断开的吗,微信小游戏开发IDE 上也需要配置好soket域名信息吗?目前还没公开注册,怎么使用socket啊?
2018-02-05 - 小程序 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 非正常关闭,求指导~~
2019-01-08