1
votes

On 25 October 2018 Miguel Grimberg the author of Flask-socketIO answered this way about Flask-socketIO on Elasticbeanstalk.

Now a year later I'm trying to do it with an app deployed on EB Python 2.7 but I can't make it work.

Miguel expressed doubts about EB not using eventlet web servers and actually I think Apache doesn't support eventlet.

Somwhere else Miguel expressed doubts about EB being multithreads but I notice that in my environment configuration there is the number of threads (NumThreads: 15).

I also found this solution for web sockets with Python and Apache (apparentely) released by AWS but I can't make it work (I actually tried with port=5000 is it right?).

A solution quite popular on the Internet is even this:

container_commands:

enable_websockets:
    command: |
     sed -i '/\s*proxy_set_header\s*Connection/c \
              proxy_set_header Upgrade $http_upgrade;\
              proxy_set_header Connection "upgrade";\
      ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf

but it doesn't seem directly relevant to the default Python EB platform with Apache web server.

So is somebody using Flask-socketIO on an EB environment and if so could she please share configuration?

1
Why do you need Apache? If you need eventlet/gevent support, then just run the server directly via socketio.run() or via gunicorn. Apache is tricky to use with Socket.IO. - Miguel
Sorry, for a moment you confused me. In your description you are talking about ELB, which is "Elastic Load Balancer", but in the title you talk about "Elastic Beanstalk", which is EB. ELB could work, EB I still doubt it, it is a very specific platform that to my understanding does not support sticky sessions, so it's not going to work. - Miguel
Miguel thanks for answering! So since I'm using EB for production and I have a lot of thing tested there, I was first trying to make it work with EB default platform that is based on Apache, that would be the easiest thing. Now I'm trying to install nginx+gunicorn with the EB .elasticbeanstalk configs which are used to config your EC2s at launch, when I'll be ready I'll publish as an answer to my question. - Marco Evasi
EB uses standard AWS components to build your platform, so you can choose an Application Load Balancer that supports sticky sessions in whichever context (EB or not). - Marco Evasi
Actually at this moment I'm stuck with flask-socketio connection swtching to long polling after a first failed attempt (which I presume made with eventlet), but I suspect it depends on errors in my code and not depending on platform. (I don't even understand if SSL may infuence somehow). - Marco Evasi

1 Answers

0
votes

I don't know if this can be considered as an answer to my original question but I have to notice that AWS Elasticbeanstalk has upgraded to platform 2 (Python3.7 + Amazon Linux2-3.0.x) that has also moved from Apache 2.4.43 to Nginx + Gunicorn.

Actually this could close the question but some interest in using the old platform with Apache is still relevant.

For example after updating to platform 2 I had to switch back to platform 1 because pipenv (that in the new platform substitues pip) fails when creating my app environment (support case opened with aws).