Websocket服务调用失败仍然调用success回调方法?
通过SocketTask wx.connectSocket(Object object)调用Websocket服务,当服务调用失败时,API仍然调用success回调方法。 let url = "ws://127.0.0.1:7070/ws";
wx.connectSocket({
url: url,
header: {
'content-type': 'text/xml'
},
protocols: ['xmpp'],
success: (message) => {
console.log(`WebSocket connection to ${url} success.${JSON.stringify(message)}`);
},
fail: e => {
throw new Error(`WebSocket connection to ${url} failed. ${e.errMsg}`);
},
complete: res => {
console.log(`WebSocket connection to ${url} complete.`)
}
日志: WebSocket connection to ws://127.0.0.1:7070/ws success.{"socketTaskId":10,"errMsg":"connectSocket:ok"} WebSocket connection to ws://127.0.0.1:7070/ws complete.