Reputation: 565
I am currently having an issue running a Flask application using flask-socketio with eventlet. When I push to AWS without eventlet my application works perfectly. This is great, however I want my application to be production ready and running flask-socketio without eventlet is slow and tedious. What I did was I broke down my application into a smaller flask application with the bare minimum requirements and code in order to test out what exactly is wrong(A link to this application is available below). This smaller application works on aws if you get rid of eventlet and it's dependencies in requirements.txt and will break if you leave them in there. After a lot of debugging and testing I still can not figure out where the source of the error comes from. Any help would be much appreciated.
On AWS I receive the following generic server error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
And in the AWS eb logs I see the following:
[Fri Feb 16 17:45:47.269584 2018] [:error] [pid 4233] import re
[Fri Feb 16 17:45:47.269592 2018] [:error] [pid 4233] File "/opt/python/run/venv/lib64/python3.6/re.py", line 142, in <module>
[Fri Feb 16 17:45:47.269750 2018] [:error] [pid 4233] class RegexFlag(enum.IntFlag):
[Fri Feb 16 17:45:47.269762 2018] [:error] [pid 4233] AttributeError: module 'enum' has no attribute 'IntFlag'
[Fri Feb 16 17:45:48.274188 2018] [:error] [pid 4233] [remote 127.0.0.1:148] mod_wsgi (pid=4233): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Fri Feb 16 17:45:48.274233 2018] [:error] [pid 4233] [remote 127.0.0.1:148] mod_wsgi (pid=4233): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
Here’s the github repo that contains my project code:
https://github.com/Freddie-Pike/Flask-SocketIO-AWS
EDIT: This setup works on localhost. It just does not work on AWS.
Upvotes: 3
Views: 1441
Reputation: 5577
Sorry, I uploaded package created with old setuptools, which does not honor this syntax enum34;python_version<"3.4"
in install_requirements
.
Please try updating pip install -U eventlet
, just released 0.22.1 that should fix this problem.
Relevant issue on Github (subscribe for news if 0.22.1 doesn't fix it): https://github.com/eventlet/eventlet/issues/463
Upvotes: 1
Reputation: 67492
This error:
[Fri Feb 16 17:45:47.269584 2018] [:error] [pid 4233] import re
[Fri Feb 16 17:45:47.269592 2018] [:error] [pid 4233] File "/opt/python/run/venv/lib64/python3.6/re.py", line 142, in <module>
[Fri Feb 16 17:45:47.269750 2018] [:error] [pid 4233] class RegexFlag(enum.IntFlag):
[Fri Feb 16 17:45:47.269762 2018] [:error] [pid 4233] AttributeError: module 'enum' has no attribute 'IntFlag'
is very likely unrelated to SocketIO. My guess is that your application has a module or package called enum
that is shadowing the enum
package from Python 3.6. Remove or rename your enum
so that Python can see its own enum
, and the error will go away.
Besides that, as Graham noted, you cannot use apache and mod_wsgi with websockets. You can consult the Flask-SocketIO documentation for the list of supported deployment configurations.
Upvotes: 1