Skip to content Skip to sidebar Skip to footer

Using Eventlet To Manage Socketio In Flask

I am trying to set up a small server to handle HTTP and socketio requests -- I don't have much experience setting up servers, but right now apache2 serves the http just fine. The s

Solution 1:

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.

Post a Comment for "Using Eventlet To Manage Socketio In Flask"