nginx服务器 部署webSocket 连接中断 前台报错码 1006

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Phoenix_smf/article/details/89278398

前台js打印websocket 关闭连接的错误信息:

console.log('websocket 断开: ' + e.code + 'reason:' + e.reason + '是否刷新' + e.wasClean)

报错码是1006
此处为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 500s;#l连接超时时间
	    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 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/Phoenix_smf/article/details/89278398
今日推荐