前台js打印websocket 关闭连接的错误信息:
console.log('websocket 断开: ' + e.code + 'reason:' + e.reason + '是否刷新' + e.wasClean)
报错码是1006 websocket错误码大全参考:https://www.cnblogs.com/EasyLive2006/p/7878668.html
此处为nginx服务器连接超时,主动断开连接,需要再nginx服务器做如下配置:
location /test{
root html;
proxy_pass http://test.com;
proxy_set_header Upgrade $http_upgrade; # allow websockets
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_connect_timeout 60s;#l连接超时时间,不能设置太长会浪费系统资源具体参考:https://www.cnblogs.com/qianbixueyuan/p/9575031.html
proxy_read_timeout 500s;#读超时时间
proxy_send_timeout 500s;#写超时时间
index index.html index.htm;
}
---------------------
作者:Phoenix_smf
来源:CSDN
原文:https://blog.csdn.net/Phoenix_smf/article/details/89227172
版权声明:本文为博主原创文章,转载请附上博文链接!