Flask-SocketIO Not Working On Apache/WSGI Flask-SocketIO Not Working On Apache/WSGI flask flask

Flask-SocketIO Not Working On Apache/WSGI


Your /var/www/public/flaskApp/flaskApp.wsgi file that Apache is running your app through doesn't use a socketio-capable server.

The tutorial you're reading states

The extension is initialized in the usual way, but to simplify the start up of the server a custom run() method is provided by the extension. This method starts gevent, the only supported web server. Using gunicorn with a gevent worker should also work.

The uWSGI documentation has a section on running in gevent mode, but Miguel commented:

uwsgi does not work with this extension either, because it does not allow a custom gevent loop to be used. Gunicorn does work, the command is in the documentation.

So, Gunicorn. From the docs:

An alternative is to use gunicorn as web server, using the worker class provided by gevent-socketio. The command line that starts the server in this way is shown below:

gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker module:app

In short, ensure that you're running with something that provides the gevent worker.