I am trying to setting up my django-socketio with uwsgi and nginx, and when I ran sudo uwsgi --ini uwsgi.ini
I got an error saying Address is already in use. I know what the problem is, I think they problem is when I ran sudo uwsgi --ini uwsgi.ini, it creates a SocketIOServer on port 80, and since my nginx is also started, it also listens to port 80. Therefore, they are conflicts, but I don't know how to solve it.
Could someone help.
My wsgi.py file looks like:
import os
PORT = 80
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
from socketio import SocketIOServer
print 'Listening on port %s and on port 843 (flash policy server)' % PORT
SocketIOServer(('', PORT), application, resource="socket.io").serve_forever()
And my nginx file looks like:
upstream django {
server unix:///tmp/uwsgi.sock;
}
server {
listen 80;
charset utf-8;
error_log /home/ubuntu/nginxerror.log ;
location /static {
alias /home/ubuntu/project/static;
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}
}
Instead of creating a socketio server in your wsgi file, use the built in runserver_socketio and start it on port 9000 using supervisor, then have nginx proxy any requests for /socket.io/ to port 9000