GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
How do I serve my Django site using uWSGI with the SocketIOServer? I tried using the following uwsgi config:
socket = 127.0.0.1:3031
master = true
processes = 2
env = DJANGO_SETTINGS_MODULE=demo.settings
module = run
and I have run.py:
from gevent import monkey
from socketio.server import SocketIOServer
PORT = 3031
os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'
application = django.core.handlers.wsgi.WSGIHandler()
SocketIOServer(('', PORT), application, namespace="socket.io").serve_forever()
but it just keeps on loading. Any ideas on how I might tell uWSGI to use SocketIOServer for serving my app?
You should probably ask this on the uWSGI lists/forums, as it's more a case of "how do I use WebSockets under uWSGI?" I believe there has been some work done in that area, but since WebSockets are essentially incompatible with the WSGI 1.0 spec, it's unlikely to work.
You also need gevent to work, and uWSGI has horrible gevent support ( http://projects.unbit.it/uwsgi/wiki/Gevent ), so I would recommend using gunicorn instead.
Hey guys, thanks will try it but I wonder if Gunicorn works with Apache? I'm pretty much stuck with it, do you think it will work the same as with Nginx if I use proxy pass in Apache to Gunicorn or do you recon there might be some issues?
Gunicorn can serve content completely independently of Apache, or you can use Apache's mod_proxy to hand requests to a backend Gunicorn server (but WebSockets won't work through mod_proxy).
@dswarbrick yayks, just as when I was thinking all request comes in apache and just forward the socketio related to gunicorn. :/ Could you enlighten me why gunicorn won't work under mod_proxy?
@marconi What I use is gunicorn with a gevent worker and nginx as a proxy with buffering off. Its very fast/scalable and works just the way you would want it to.
@sontek the thing is, our sysad is quite attached to Apache. I'll give it another shot, might be able to convince him this time. :)
Yeah, you can use apache. I know someone who does HAProxy + Apache but I haven't done it.
@sontek Can you elaborate on what you mean by using nginx as a proxy? Is that proxying WebSockets?