我能够正确接收套接字发出的消息,但是每当在开始时加载页面时,我仍然会收到此握手错误。
WebSocket connection to 'ws://example.com/socket.io/?EIO=3&transport=websocket&sid=SBznqHMs6-4SHOdSAAAq' failed: Connection closed before receiving a handshake response
我正在使用nginx代理将流量定向到多个node.js应用。这些是我的nginx配置。
upstream app1 {
ip_hash;
server 127.0.0.1:3004;
}
server {
listen 0.0.0.0:80;
server_name example.com;
location / {
proxy_pass http://app1;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_cache_bypass $http_upgrade;
}
}
虽然套接字工作正常,但这次握手错误让我烦恼。希望任何遇到此错误的人都可以了解我:)
答案 0 :(得分:0)