Raise Runtimeerror('you Need To Use The Eventlet Server. '
In my project, I created a app: the website_chat/views.py code: async_mode = 'eventlet' import os from django.http import HttpResponse import socketio basedir = os.path.dirname
Solution 1:
In the end, I do not follow the example of python-socketio
, I configure the wsgi.py
like bellow:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Qyun.settings")
from socketio import Middleware
from website_chat.views import sio
django_app = get_wsgi_application()
application = Middleware(sio, django_app)
#import eventlet
import eventlet.wsgi
eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
It works for this issue now. the port still is 8000
, and the management/commands/runserver.py
also can be delete now.
Solution 2:
If this error happens when you try to run your app into an uwsgi environment such us:
uwsgi -w myfile:app\
--http11-socket 127.0.0.1:3333\
--enable-threads\
--threads 4\
--logformat '%(addr) - %(user) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"'
where myfile.py
contains the application:
import socketio
import eventlet
from engineio.async_drivers import gevent
from flask import Flask
sio = socketio.Server(async_mode="gevent_uwsgi", cors_allowed_origins='*', engineio_logger=True)
app = Flask(__name__)
# this generates the uwsgi-runnable application
my_wsgi = socketio.WSGIApp(sio)
app = socketio.Middleware(sio, my_wsgi)
If you have errors installing gevent by
pip3 install gevent
probably pip will try to install some of the last gevent versions:
21.1.0, 21.1.1, 21.1.2
This may lead to installing errors depending the operative system you use (some issues with darwin). To overcome these errors, it also works using simpler, older versions of gevent:
pip3 install gevent==1.5.0
Post a Comment for "Raise Runtimeerror('you Need To Use The Eventlet Server. '"