Thank you in advance! On Monday, February 18, 2019 at 4:14:44 PM UTC-5, [email protected] wrote: > > Hi, > > The real-time discussion function (supported by Daphne) on my website is > not working (Other non-real-time functions are good). The console echos: > "WebSocket connection to 'ws://xxxforum/room_xxx/' failed: Error during > WebSocket handshake: Unexpected response code: 200". I've went through the > blog posts and the documentation but couldn't find a solution. Can anyone > help? > > I am attaching information that I think is needed. If you need any other > information please let me know. > > *The non-real-time part is supported by uwsgi* (I know it can be > supported by Daphne too. But since the real-time part is not working I > decide to use uwsgi): > uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=666 > --processes=6 > > *daphne*: > daphne mysite.asgi:channel_layer --port 8000 --bind 0.0.0.0 -v2 & > python manage.py runworker -v2 & > > *nginx configuration:* > upstream websocket { server 0.0.0.0:8000; } server { listen 80; > server_name mysite.com; charset utf-8; client_max_body_size 20M; location > /static { alias /path/to/mysite/static; } location / { include > /etc/nginx/uwsgi_params; > uwsgi_pass unix:///path/to/mysite/mysite.sock; } location /ws { proxy_pass > http://websocket; proxy_http_version 1.1; proxy_set_header Upgrade > $http_upgrade; > proxy_set_header Connection "upgrade"; > proxy_redirect off; > proxy_set_header Host $host; > proxy_set_header X-Real-IP $remote_addr; > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; > proxy_set_header X-Forwarded-Host $server_name; > } > } > > One thing that I don't understand is that if I try to use Daphne to > support both real-time and non-real-time communication by deleting the > uwsgi block "location / {}" and renaming "location /ws {}" to "location / > {}" the nginx service cannot be restarted. Does it suggest any bug? > > *first few lines in .js related to the discussion function:* > $(function() { > var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws"; var > chatsock = new ReconnectingWebSocket(ws_scheme + '://' + > window.location.host + window.location.pathname); > ...... > >
-- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2bf2a20d-2650-49e6-a9e3-f0602b498a0a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

