建立连接后成功,进入成功回调,但是onSocketOpen和onSocketMessage都不打印,求解,代码如下:
onLoad: function (options) {
wx.connectSocket({
url: 'ws://xxx.xx.xxx:80xx/xxx/websocket/',
data: {},
header: {
'content-type': 'application/json'
},
method: 'GET',
success: function (socketRes) {
console.log('connect success: ', socketRes);
},
fail: function (err) {
console.log('connect error: ', err)
}
});
wx.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!')
})
wx.onSocketMessage(function (res) {
console.log('收到服务器内容:' + res.data)
})
}
请检查是否连接建立失败了,可以用 wx.onSocketError 监听错误事件
我也碰到这个问题,但是,我用wx.onSocketError监听却没有返回值,然后还是连接不上,怎么解决???
我是连接成功,onSocketOpen和onSocketError都没调用,不知道怎么回事?
Socket连接失败,报错如下: java.security.cert.CertPathValidatorException:Trust anchor for certification path not found
监听出来就是这个错误:
com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sun Feb 18 07:59:59 GMT+08:00 2018 (compared to Sat Mar 03 09:49:20 GMT+08:00 2018)
com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sun Feb 18 07:59:59 GMT+08:00 2018 (compared to Sat Mar 03 09:49:20 GMT+08:00 2018)
我也是出现这种情况