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.
What's your client like?
Could I call your attention to this issue for socketio-client?
The problem is that for some reason I could not diagnose, the background_task for sending packets out doesn't get started for a socket. So a queue.join() call deadlocks and the server does not receive messages from the client.
A fix is needed in some combination of flask-socketio, python-engineio and socket-client, though I remain mystified as to why the JS Socketio client does not cause this deadlock.
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.
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.
@harsha-kadekar do you have a complete application I can use to reproduce the issue?
[https://github.com/harsha-kadekar/Chitralochana/tree/master/Chitralochana_app]
I am developing this, where I have used socket for communication from backend to frontend.
@miguelgrinberg Not sure this is helpful or not....
@harsha-kadekar are you monkey patching the python standard library when you use eventlet? That's probably required in your case, given the dependencies that you use.
I have not done it. Let me try it and will get back to you once tested it.
@miguelgrinberg I'm also having the same problem I just tried monkey patching with:
import eventlet
eventlet.monkey_patch()
....
socketio.run(app, host='0.0.0.0', debug = False, use_reloader=False)
I got the following error:
File "/usr/lib/python2.7/dist-packages/numexpr/expressions.py", line 64, in init
raise SystemError('init called too many times')
SystemError: init called too many times
Any help would be great, my project can be found here: https://github.com/BrandonJoffe/home_surveillance
@BrandonJoffe Unfortunately this appears to be a limitation of the numexpr package. There is an open bug for this error: https://github.com/pydata/numexpr/issues/118.
Thanks @miguelgrinberg I'm still relatively new to Flask and I'm looking to deploy a Flask-SocketIO server. I just tried gevent on WSGI which gave me the same issues. I'm assuming this is a compatibility issue. Do you recommend I try Gunicorn and Gevent? Any pointers in the right direction will be incredibly helpful.
Thanks again.
My guess is that eventlet and gevent are going to be incompatible with numexpr in the same way, regardless of what web server you use. If you can't find a replacement for numexpr that works with green threads, then you can use Flask-SocketIO with the Flask development server, which does not require any external async frameworks. The disadvantage is that there is only long polling support in this mode, but to your application on the server and the client there should not be any difference other than performance, since this is all handled internally in a transparent way.
Ok I guess long polling will have to do for now, thanks.
On Oct 10, 2016, at 11:05 PM, Miguel Grinberg [email protected] wrote:
My guess is that eventlet and gevent are going to be incompatible with numexpr in the same way, regardless of what web server you use. If you can't find a replacement for numexpr that works with green threads, then you can use Flask-SocketIO with the Flask development server, which does not require any external async frameworks. The disadvantage is that there is only long polling support in this mode, but to your application on the server and the client there should not be any difference other than performance, since this is all handled internally in a transparent way.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/miguelgrinberg/Flask-SocketIO/issues/255#issuecomment-252746247, or mute the thread https://github.com/notifications/unsubscribe-auth/ATLLifj9UvV55ZJQGJTksPYkZa7E-NsMks5qyqiogaJpZM4IKf9l.
Closing due to inactivity. Please reopen if the problem still exists.
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?
I'm still pretty stuck on this too, using a small test app running in Docker. I've tried adding async_mode='eventlet' to the socketio.run() line, and that sometimes helped. But then when I removed that argument, the RuntimeError: You need to use the eventlet server would still not show up. It seems like the suggested solution is to use socketio.run(app), but I'm already doing that.
I've looked at several related issues on this repository like 257, 279, 649, but I'm still on this bug
Here's my flask app (partyproject.py)
```from flask import Flask
import eventlet
from flask_socketio import SocketIO
app = Flask(__name__)
socketio = SocketIO(app)
@app.route("/")
def hello():
return "
if __name__ == '__main__':
socketio.run(app)
Here's `wsgi.py`:
```from partyproject import app, socketio
if __name__ == '__main__':
socketio.run(app)
Here's my Dockerfile:
FROM ubuntu:16.04
COPY . /home
WORKDIR /home
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN apt-get update -y && \
apt-get -y upgrade && \
apt-get -y install python3-pip python3-dev build-essential \
libssl-dev libffi-dev python3-setuptools openssh-server docker.io && \
pip3 install uwsgi flask flask-socketio==3.0.1 wheel eventlet==0.23.0 \
flask-socketio==3.0.1
EXPOSE 5000
EXPOSE 80
COPY partyproject /etc/nginc/sites-available/partyproject
CMD ["uwsgi", "--socket", "0.0.0.0:5000", "--protocol=http", "-w", "wsgi:app"]
@Joshua-Swain you are using uWSGI, which as far as I know is incompatible with eventlet. Have you seen the documentation? I show all the configurations that I have personally tested and found to work. I suggest you use one of those.
That explains it. Yeah I used the configuration suggested for uWSGI and the app runs now. Thanks for the help!
Hi Miguel, I'm using socketio to send some audio packets. All works just fine but I'm using the development server.
As soon as installed eventlet the audio packets aren't working any more, other socketio packets are fine, only audio is the problem.
Some times I get this message in the browser:
WebSocket connection to 'ws://192.168.0.103:5000/socket.io/?EIO=3&transport=websocket&sid=370d67a8086e4e77a34bc8e1356aff8f' failed: Received a broken close frame containing invalid UTF-8.
If I uninstall eventlet all works again!
@MarianoDel hard to comment on this without details. Do you think you can create a small example app that I can try here to reproduce the issue? If you can, please file a separate issue and provide the code.
Hi Miguel, I'm think I forget mokey paching, will try this and get a feddbak.Thanks for your answer!!!
Mariano E. Deleu [email protected]
El viernes, 10 de julio de 2020 05:14:02 ART, Miguel Grinberg <[email protected]> escribió:
@MarianoDel hard to comment on this without details. Do you think you can create a small example app that I can try here to reproduce the issue? If you can, please file a separate issue and provide the code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Most helpful comment
After running
pip install eventletI getIs there something I'm not getting here?