我的设置是cloudflare - > nginx - > node.js服务器.我已经确认它不是node.js服务器.问题似乎是cloudflare和nginx的结合.它只适用于nginx和node.js.
这是nginx为websocket连接记录的内容:162.158.75.125 - - [29/Oct/2016:00:01:47 +0000]"GET/HTTP/1.1"101 1047" - ""Mozilla/5.0(X11; Linux x86_64)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/53.0.2785.143 Safari/537.36"
nginx配置:
server {
listen 443 ssl;
server_name vectorwar.io;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
location / {
proxy_pass http://localhost:7000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 31104000s;
proxy_connect_timeout 31104000s;
proxy_send_timeout 31104000s;
}
}
Run Code Online (Sandbox Code Playgroud)
您是否尝试过在没有 SSL 的情况下设置 Websocket?
我有过这样的经历:通过 SSL 进行的 Websockets 在大约 45 秒后自动断开连接。使用不安全的连接解决了这个问题。显然并不理想,但您可以尝试看看这是否至少解决了断开连接问题。
| 归档时间: |
|
| 查看次数: |
864 次 |
| 最近记录: |