注意事项: 在nginx中握手后无交互,默认60s断开
解决办法:
1.可以使用心跳包,每多少时间发送心跳包
2.修改nignx的proxy_read_timeout 的数值
修改nginx配置
http{
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
…………省略…………
server {
listen 80;
server_name localhost;
location /websocket/ {
proxy_pass http://localhost/websocket/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 600s;
}
}
}