NGINX, Websockets, Multiple Instances and ELB w/ Stickiness

0

All,

I'm having troubles with a websocket "push" to one instance being transmitted to other instances on an Elastic Load Balancer. I have 2 instances, and I'm testing on 2 clients. When Client A adds a new record to the database, a graphQL subscription is triggered to send that record to all devices subscribed. Client B isn't getting the data sent to it. However, when both clients end up on the same instance, they do receive updates (as expected). I've tried configuring the custom conf various ways, and to no avail. There can be anywhere to over 2000 clients, and they'll need to have the same updates being dispatched to them. This used to work flawlessly with one instance. Below is the content of the custom.conf.

I appreciate your time and help in the matter, thanks!

client_max_body_size 100M;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
client_header_timeout 600;
client_body_timeout 600;
keepalive_timeout 600;

upstream graphql {
    server 127.0.0.1:5000;
}

server {

  listen 443;
  server_name   *.eatedigital.com;
  large_client_header_buffers 4 512k;
  proxy_buffers 4 512k;
  proxy_buffer_size 512k; 
  proxy_busy_buffers_size 512k;

  location / {
        proxy_pass https://127.0.0.1:5000;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

    location /api {
        proxy_pass https://127.0.0.1:5000/api;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

     location /api/graphql {
        proxy_pass https://graphql/api/graph;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
}

server {

  listen 80;
  listen 5001;
  server_name   *.eatedigital.com;
  large_client_header_buffers 4 512k;
  proxy_buffers 4 512k;
  proxy_buffer_size 512k; 
  proxy_busy_buffers_size 512k;

  location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

    location /api {
        proxy_pass http://127.0.0.1:5000/api;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }

     location /api/graphql {
        proxy_pass http://graphql/api/graph;
        proxy_connect_timeout 75s;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
}

he load balancer has stickiness enabled and for 1 day

1 Answer
0

I was able to resolve my issue using this article, How to create real-time chat applications using WebSocket APIs in API Gateway. The author, Trong Pham, was great in explaining, and demoing, a solution that uses websockets via the API Gateway service. It took 10 minutes to set up in AWS and with his .NET solution. Seeing how it functions via the backend made it easy to swap out the GraphQL and Apollo WebSocket library and implementation.

DevOn
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions