onSocketError
websocket连接服务器错误时
小程序端会触发 onSocketError,onSocketClose 这两个事件
而 app端只会 触发 onSocketError 不会触发 onSocketClose
代码如下:
public static websocketConnect() {
uni.connectSocket({
url: CommonUtil.websocketUrl + 'webSocket/message,
complete(res) {
console.log(res)
}
})
uni.onSocketOpen(res => {
console.log(res)
})
uni.onSocketError(res => {
console.log("触发了错误")
})
uni.onSocketClose(res => {
console.log("触发了关闭")
})
}
1条答案
按热度按时间ehxuflar1#
小程序端为
电脑上的 微信开发者工具和qq开发者工具
app端为 安卓的三星 s10 也是开发状态下