Using eventlet to manage socketio in Flask Using eventlet to manage socketio in Flask flask flask

Using eventlet to manage socketio in Flask


To make a WSGI application available online you need to expose it through a web server. When your application uses Flask-SocketIO, a plain WSGI web server isn't sufficient, because WSGI does not support WebSocket, the WSGI protocol needs unofficial extensions to support this protocol.

Flask-SocketIO supports a variety of web servers that support WebSocket. It appears you have eventlet installed in your virtual environment, so that is why you receive the error that you have to use the eventlet web server.

What you don't seem to realize, is that you are using Apache's web server (I'm guessing mod_wsgi?). This web server is a normal, forking web server, it is not an eventlet compatible web server.

Isn't the socketio.run(app) supposed to start the eventlet server for me?

Yes, if you were to run your application via socketio.run(app) you would get a fully enabled eventlet web server. But you are not doing that, you are running it on apache. Eventlet has a web server, and apache has a web server, they are two separate web servers, both able to run a WSGI application. But the apache one does not support WebSocket.

The Flask-SocketIO documentation describes a few deployment scenarios that are valid.