mercredi 24 juin 2015

Websocket handshake error message on AWS EC2, Nginx

I am able to receive socket emitted messages properly but I am still receiving this handshake error whenever the pages is loaded at the start.

WebSocket connection to 'ws://example.com/socket.io/?EIO=3&transport=websocket&sid=SBznqHMs6-4SHOdSAAAq' failed: Connection closed before receiving a handshake response

I am using nginx proxy to direct the traffic to several node.js apps. These are my nginx configuration.

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;
    }

}

Although the socket works fine but this handshake error is bothering me. Hope anyone who came across this error can shed light on me :)




Aucun commentaire:

Enregistrer un commentaire