0

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;
        }
    }
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
user2002692
  • 971
  • 2
  • 17
  • 34

2 Answers2

0

I was looking at django-socketio recently, I remember I only let socketio listen on port 843. Any reason why you need to listen on both 80 & 843?

under development, you may add open port 843, and see if this solves your problem.

anzel
  • 31
  • 3
0

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

Isaac Ray
  • 1,351
  • 9
  • 17