赞
踩
当我们点击发送消息时,触发onclose 事件
that.ws.onclose = function(e) {
// 关闭 websocket
console.log('连接已关闭...');
console.log(e.code + e.reason + e.wasClean);
//延迟执行重连
setTimeout(() => {
that.creatSocket();
}, that.$global.delay);
};
输出:连接已关闭…
1002 An unrecoverable IOException occurred so the connection was closed true
解决方案:
this.messageInfo.message = this.message;
// this.messageInfo.user_id = this.userInfo.userId;
this.messageInfo.orgId = getCookie('setOrgId');
var message = JSON.stringify(this.messageInfo);
console.log('message==socket', message);
that.ws.send(message);
检查send方法里面的参数,例如:
上面的代码的报错原因是将参数user_id注释了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。