勾选了不校验合法域名,模拟器上没问题,真机调试就报错
createTCP(){
const tcp = wx.createTCPSocket()
tcp.onConnect(function listener(){
that.updataStaus("tcpConnectSuccess")
console.log("tcpConnectSuccess")
})
tcp.onClose(function listener(){
console.log("tcpOnClose")
})
tcp.onError((res) => {
console.log("错误:", res)
})
const listener1 = function (res) {
let str = new Uint8Array(res.message)
console.log(res) }
tcp.onMessage(listener1)
tcp.connect({address: 'xxxxxxxxx', port: 2222, timeout: 10})
}
感觉这个不校验合法域名有问题,配置好域名后就好了