码迷,mamicode.com
首页 > Web开发 > 详细

Socket.IO failed: Error during WebSocket handshake:

时间:2017-02-28 21:00:09      阅读:364      评论:0      收藏:0      [点我收藏+]

标签:技术   分享   png   during   port   监控   param   its   socket   

    在node安装了Socket.IO,做demo时报错

    WebSocket connection to ‘ws://localhost:8999/socket.io/?EIO=3&transport=websocket&sid=D0fxLuPwjHWgYSI7AAAB‘ failed: Error during WebSocket handshake: Unexpected response code: 400

 技术分享

    WebSocket 握手时发生错误,诡异的是我前端页面没有关闭,重启服务器node app.js后socket重新连上了

    经多次测试验证,只有登陆进入才会报错,但是之后Socket 是处在连接状态的如图,连接不是很稳定,cookie也可以获取到。重启之后可以socket自动连上。

 技术分享

    这就奇怪了。。折腾了许久,另外写了个更简单的demo, 只要必要的express和socket.io, 发现没问题。

    然后排查,最后找到了这货

 技术分享

 技术分享

    express-status-monitor

    基于socket.io和chat.js的服务器监控器

    可能会存在冲突,把这个注释之后,可以了!

    然后在express-status-monitor, 找到了原因:

    If you‘re using socket.io in your project, this module could break your project because this module by default will spawn its own socket.io instance. To mitigate that, fill websocket parameter with your main socket.io instance as well as port parameter.

Socket.IO failed: Error during WebSocket handshake:

标签:技术   分享   png   during   port   监控   param   its   socket   

原文地址:http://www.cnblogs.com/knightreturn/p/6480693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!