I have a Flask application running on AWS Application Load Balancer, but can't get web sockets to work. After reading several posts and configuring Load Balancers, Target Groups, stickiness on EC2, I came to the conclusion that it might be that ALB is not staring the application correctly.
Flask-SocketIo says to use socketio.run(application, host='0.0.0.0', port=port) to start up the web server as it encapsulates application.run(). But after further reading I found that EC2 already calls application.run() without the need of explicitly doing so in the start up script, and therefore it might just bypassing my socketio.run() and not be starting my web server.
Could this be the case? How can I verify it and make sure socketio is started properly?
To access the application via Load Balancer you have to make sure first that your target in Target Group is healthy. The health status is displayed in AWS Web console on your target group instance details on Targets tab.
If there are no targets in your Target Group, add one by pressing Edit button and selecting your EC2 instance from the list. Don't forget to use the appropriate port. Also make sure health checks are configured correctly (path, port...). You can find them on Health Checks tab of your target group details page.
If all above is ok and you have a healthy target in TG, but the ELB doesn't show your application, I'd recommend you to SSH to your EC2 instance with Flask app and check if that one is running correctly.
flask-socketio run on Application Load Balancer