that.localSocket = wx.connectSocket({
url: "wss://test.xxxxxx.com/web/xxxxx/",
success: data => {
onsole.log('socket 连接成功', data);
//this.initSocketListener();
},
fail: data => {
console.error('socket 连接失败', data);
},
})
that.localSocket.onOpen(function (res) {
console.log('WebSocket连接已打开!readyState=' + that.localSocket.readyState);
console.log(res, '打开的res数据');
})
that.localSocket.onMessage(function(res) {
console.log('接收socket消息')
console.log(res)
})
that.localSocket.onError(function(res) {
console.log('socket报错信息', res)
console.log('readyState=' + that.localSocket.readyState)
})
that.localSocket.onClose(function (res) {
console.log('WebSocket连接已关闭!readyState=' + that.localSocket.readyState)
console.log(res, '关闭的res数据')
})
链接被打开后就自己立即再关闭了,请问下这是什么问题?
同问