I have set up a server on AWS Fargate and I connect to the Application Load Balancer via Socket.io.
I have enabled the access logs of the Application Load Balancer and the logs are as follows:
http 2018-12-25T04:00:15.787118Z app/EC2Co "GET http://ec2co.us-east-2.elb.amazonaws.com:28656/socket.io/?EIO=3&transport=polling&t=1545710415657-0 HTTP/1.1" "python-requests/2.20.0" - - arn:aws:elasticloadbalancing:us-east-2:735263141676:targetgroup/EC2Co-Defau-8X "Root=1-5c21ab4f-f26e11527cb2fa030ade3020" "-" "-" 0 2018-12-25T04:00:15.777000Z "forward" "-" "-"
ws 2018-12-25T04:00:14.548103Z app/EC2Co "GET http://ec2co.us-east-2.elb.amazonaws.com:28656/socket.io/?EIO=3&transport=websocket&sid=ils820o21XTc_rlnAAAA HTTP/1.1" "python-requests/2.20.0" - - arn:aws:elasticloadbalancing:us-east-2:735263141676:targetgroup/EC2Co-Defau-8X "Root=1-5c21ab27-560b3f40746e96c087a97ec0" "-" "-" 0 2018-12-25T03:59:35.646000Z "forward" "-" "-"
ws 2018-12-25T04:14:38.103181Z app/EC2Co "GET http://ec2co.us-east-2.elb.amazonaws.com:28656/socket.io/?EIO=3&transport=websocket&sid=lO2XYpIjTe_9p4s7AAAA HTTP/1.1" "python-requests/2.20.0" - - arn:aws:elasticloadbalancing:us-east-2:735263141676:targetgroup/EC2Co-Defau-8X "Root=1-5c21ab50-f024082cf6db65724f6384c0" "-" "-" 0 2018-12-25T04:00:16.360000Z "forward" "-" "-"
http 2018-12-25T04:14:39.359703Z app/EC2Co "GET http://ec2co.us-east-2.elb.amazonaws.com:28656/socket.io/?EIO=3&transport=polling&t=1545711279222-0 HTTP/1.1" "python-requests/2.20.0" - - arn:aws:elasticloadbalancing:us-east-2:735263141676:targetgroup/EC2Co-Defau-8X "Root=1-5c21aeaf-8a69112ff7361e029ddedf81" "-" "-" 0 2018-12-25T04:14:39.344000Z "forward" "-" "-"
As you can see, the connection is upgrading to websocket
connection correctly but downgrading to polling
.
I wanted to know if this is normal behaviour?
The connection between the client and the Application Load Balancer keeps resetting approximately every 2 minutes, sometimes lesser than 2 minutes even if I send a ping
to the load balancer every minute.
Also, the health checks of the load balancer keep failing and none of the targets become healthy.
I have not explicitly defined the message 200 ok
in my client code for the load balancer to receive. Do I have to explicitly define the 200 ok
message? If yes, then what is the event that the load balancer sends during these health checks?
The constant disconnect is causing some of the inputs from the client to the load balancer and in turn the AWS Fargate server to be lost.
I am using express
on my server. Below is the relevant code from app.js on the server:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var AWS = require ('aws-sdk');
Please note that the server code is in Nodejs
, however the client code is in Python
. Does that make a difference and causes disconnects?
So, is this normal behaviour (seeing the logs above)? Or is there something I am missing?
Also, how can I define the 200 ok
message to be sent to the load balancer when it does the health checks so that my targets become healthy?
If there is any information I have missed and you require in order to answer this question, please comment below and I will edit the question to provide the required information.
Thanks.