建立websocket连接代码如下
this.m_webSocket = wx.connectSocket({
url: wxServerSrc
})
console.log(this.m_webSocket)
wx.onSocketOpen(function (res) {
console.log("onSocketOpen12")
//console.log(Msg.CS_MsgWeiXingLogin(code,res2.userInfo.nickName))
// wx.sendSocketMessage({
// data:Msg.CS_MsgWeiXingLogin(code,res2.userInfo.nickName)
// })
console.log("name:"+name+" avatar:"+avatar)
this.m_webSocket.send({
data:Msg.CS_MsgLogin(code,name,avatar,"wx")
})
}.bind(this))
wx.onSocketError(function (res) {
console.log(res)
console.log('WebSocket 连接打开失败,请检查!')
if( this.loginFail != null){
this.loginFail()
}
}.bind(this))
wx.onSocketClose(function (res) {
console.log('WebSocket 连接关闭!')
this.m_webSocket = null
//
cc.director.loadScene("Login", null);
}.bind(this))
wx.onSocketMessage(function (res) {
//console.log('WebSocket 收到消息')
//console.log(res)
MsgManager.getInstance().ParseMsg(res.data)
}.bind(this))
} else {
console.log('获取用户登录态失败1!' + res.errMsg)
if( this.loginFail != null){
this.loginFail()
}
}
}.bind(this),
fail: function (res) {//登录成功
console.log('获取用户登录态失败2!' + res.errMsg)
if( this.loginFail != null){
this.loginFail()
}
}.bind(this)
打印
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
WebSocket 连接打开失败,请检查!
这个问题怎么解决啊?ios正常,android报错
请问楼主问题解决了吗?我也遇到这个问题了
是字符串的问题
啥子字符串问题?能说具体一点吗
看上去像是证书有问题,建议和后台同学一起排查一下