dcloudio / dcloudio/uni-app

websocket连接服务器错误时app端和小程序端触发事件不一致

Open
#1,619 1 comment 0 reactions 1 assignee Claimed by @Otto-J View on GitHub
不明确复现步骤、未提供复现工程
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

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("触发了关闭")
})
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.