Monday, 29 May 2017

Error with Loadbalancing, Websockets and NodeJS

I have two NodeJS application with socket.io, which sits behind a local (docker) NGINX loadbalancer. Wenn only one application is up everything works fine. When I add the second I get the following error on every second reload or so.

WebSocket connection to 'wss://[HOST]/socket.io/?EIO=3&transport=websocket&sid=9CmO27cJsdmqMwwXAAAK' failed: Error during WebSocket handshake: Unexpected response code: 400

here my NGINX config:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    upstream myhost {
        least_conn;
        server 192.168.99.1:3333;
        server 192.168.99.1:4444;
    }

    server {
        listen 80;
        listen 443 ssl;
        server_name         [HOST];
        ssl_certificate     server.crt;
        ssl_certificate_key server.key;

        location / {
            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 Host $host;
            proxy_http_version 1.1;
            proxy_pass http://myhost;
        }
    }
}



via refextu

No comments:

Post a Comment