Hi,
I can't quite get Flask-SocketIO working with my instance on AWS Elastic Beanstalk (ELB), with the requirement of running Flask-SocketIO with socketio.run(application), ELB appears to make the calls to the global application object itself.
The ELB documentation states Using application.py as the filename and providing a callable application object (the Flask object, in this case) allows Elastic Beanstalk to easily find your application's code.
My ELB instance logs show the error RuntimeError: You need to use the eventlet server. See the Deployment section of the documentation for more information.
Is there any way to approach this problem assuming that AWS calls application.run()?
Thanks in advance
Not sure ELB environment is compatible with Flask-SocketIO. First of all, I doubt ELB supports eventlet. Second, SocketIO requires a multithreaded web server, because each client sends two concurrent HTTP requests, and both need to be handled in parallel in the same process. I'm not 100% about this, but I think ELB is multiprocess, not multithreaded.
You should be able to deploy a Flask-SocketIO app to a EC2 instance, or as a container on ECS, but the ELB platform is too specialized, it's not a good solution for the SocketIO server, which is kind of unusual in its requirements.
@miguelgrinberg - Would you say using the solution here, https://github.com/miguelgrinberg/Flask-SocketIO/issues/625, would be good? Basically, running the Flask app in a Docker container in order to use ElasticBeanStalk?
@golharam I have never tested this type of deployment, but I think it could work. Flask-SocketIO is 100% compatible with Docker, but if you plan on deployment multiple workers you will need to set sticky sessions for the load balancer.