当前位置:   article > 正文

websocket 点解发送 连接已关闭..._an unrecoverable ioexception occurred so the conne

an unrecoverable ioexception occurred so the connection was closed

当我们点击发送消息时,触发onclose 事件

 that.ws.onclose = function(e) {
                    // 关闭 websocket
                    console.log('连接已关闭...');
                    console.log(e.code + e.reason + e.wasClean);
                    //延迟执行重连
                    setTimeout(() => {
                        that.creatSocket();
                    }, that.$global.delay);
                };
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

输出:连接已关闭…
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);
            
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

检查send方法里面的参数,例如:
上面的代码的报错原因是将参数user_id注释了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/770763
推荐阅读
相关标签
  

闽ICP备14008679号