Flask-SocketIO: Flask-SocketIO doesn't work with eventlet

As soon as I install eventlet, my app stops working. I can still see logs and incoming connections, but I stop receiving messages and events from the client.

I reproduced this with the following code:

from flask import Flask
from flask_socketio import SocketIO, emit

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
app.config['DEBUG'] = True
socketio = SocketIO(app)


@app.route('/')
def index():
    return "Hello"


@socketio.on('message')
def test_message(message):
    print "Received {}".format(message)
    emit("echo", message)


if __name__ == '__main__':
    socketio.run(app)

No changes in my client that just sends a “message” event and listens to “echo” events.

my pip-freeze:

eventlet==0.18.4
Flask==0.10.1
Flask-SocketIO==2.2
greenlet==0.4.9
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
python-engineio==0.9.0
python-socketio==1.2
six==1.10.0
Werkzeug==0.11.8
wheel==0.24.0

If I uninstall eventlet (pip uninstall eventlet) everything works fine. Is this some versioning problem? I couldn’t find anything like this online.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 26 (11 by maintainers)

Most upvoted comments

After running pip install eventlet I get

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/flask_socketio/__init__.py", line 42, in __call__
    start_response)
  File "/usr/local/lib/python2.7/dist-packages/engineio/middleware.py", line 47, in __call__
    return self.engineio_app.handle_request(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/socketio/server.py", line 353, in handle_request
    return self.eio.handle_request(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/engineio/server.py", line 261, in handle_request
    environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/engineio/socket.py", line 89, in handle_get_request
    start_response)
  File "/usr/local/lib/python2.7/dist-packages/engineio/socket.py", line 136, in _upgrade_websocket
    return ws(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/engineio/async_eventlet.py", line 11, in __call__
    raise RuntimeError('You need to use the eventlet server. '
RuntimeError: You need to use the eventlet server. See the Deployment section of the documentation for more information.

Is there something I’m not getting here?

Hi, even I am facing the same issue. Server side works normally but client side shows no activity yet all. Once I uninstall eventlet it starts working fine.

I think I need some help in running the code and getting it to deadlock. I was able to start the server, but then when I run the client there is a short exchange and the client exits.