django-websocket-redis icon indicating copy to clipboard operation
django-websocket-redis copied to clipboard

Question: Would it do any harm if I kept my Django running on a normal WSGI server behind ngnix and then the websocket on a uwsgi server behind the same ngnix server?

Open gabn88 opened this issue 10 years ago • 2 comments

I have already a stable production website running Django, which I want to give websocket powers.

This project seems to be perfect for my use case as I have Django running on wsgi and already behind an ngnix server. This ngnix server is already configured to serve ws.mydomain.com requests to a custom websocket (using a TCP connection instead of a socket, but that should not matter, right?).

Now I would like to know if my setup has any chance of going to work, I would like to start a new uwsgi server to serve the requests from my custom websocket port to the redis backend using django-websocket-redis. Is this going to work?

gabn88 avatar Oct 26 '15 20:10 gabn88

I would like to start a new uwsgi server to serve the requests from my custom websocket port to the redis backend

Yes, that's the intention of this project.

However, you don't even need custom websocket port, you can even use the same port you use for normal HTTP(S) and separate them on nginx using a special path prefix, say /ws.

jrief avatar Oct 27 '15 07:10 jrief

Wow, I have read all night about it and you have really done amazing work. Thank you so much for your answer and all the time you have spend on this!

I have set up everything for my development server, but I get the following error when I go to localhost/ws:

Traceback (most recent call last): File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/home/gerben/.virtualenvs/skillshare/lib/python3.4/site-packages/django/contrib/staticfiles/handlers.py", line 64, in call return self.application(environ, start_response) File "/home/gerben/.virtualenvs/skillshare/lib/python3.4/site-packages/ws4redis/django_runserver.py", line 85, in application return _websocket_app(environ, start_response) File "/home/gerben/.virtualenvs/skillshare/lib/python3.4/site-packages/ws4redis/wsgi_server.py", line 134, in call start_response(force_str(status), response._headers.values()) File "/usr/lib/python3.4/wsgiref/handlers.py", line 226, in start_response self.headers = self.headers_class(headers) File "/usr/lib/python3.4/wsgiref/headers.py", line 34, in init raise TypeError("Headers must be a list of name/value tuples") TypeError: Headers must be a list of name/value tuples

Any pointers what the reasons is? Bdw, I'm using python3.4 and the latest release of django-websocket-redis from github.

Never mind.. I was using the browser to test the websocket, which of course didn't work. I found a handy chrome extension (simple websocket) and when I go to ws://0.0.0.0:7999/ws/ it says opened and it seems to work. Thank you!

gabn88 avatar Oct 27 '15 07:10 gabn88