昨天还好好代码都没改动突然就连接不上了 代码跟控制台打印如下:
connect() {
var that = this
getApp().globalData.localSocket = wx.connectSocket({
url: ‘wss://www.zhongjurl.com/wss/wanxiangzhixun/websocket/’ + getApp().globalData.openid,
})
console.log(getApp().globalData.localSocket)
getApp().globalData.localSocket.onOpen(function(res) {
console.log(‘连接已打开’)
})
getApp().globalData.localSocket.onError(function(res) {
console.log(‘连接发生错误’)
})
getApp().globalData.localSocket.onClose(function(res) {
console.log(“连接已关闭”)
console.log(res)
if (res.code != 1000) {
console.log(‘重新连接’)
that.connect()
}
})
}
连接完触发了onOpen事件但是socket.readystate=3 完了隔2秒直接触发了onClose还是显示正常关闭 onError没触发