3

I am trying to run the multichat project from django channels-examples on a server. It works locally on a windows machine but when I put this on the linux server and start it with runserver it does not:

./manage.py runserver

Then when I call up the website, it is shown correctly but as soon as the JS sends it websocket request I always get this reponse:

[2016/08/02 14:35:48] HTTP GET /chat/stream/ 404 [0.04, 127.0.0.1:40186]
....(many lines of this)

So the websocket request is handled as an http request. The response should be this:

[2016/08/02 16:34:45] WebSocket CONNECT /chat/stream/ [127.0.0.1:60250]

I have no clue where this is going wrong. The routing of http versus websocket seems to be done somewhere deep inside daphne/twisted/...

My channel settings are (if that is of any help at all):

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
            "hosts": [(redis_host, 62031)],
        },
        "ROUTING": "multichat.routing.channel_routing",
    },
}

Twisted version is 16.2.0.

Any help or hint in what direction to look is very appreciated.

1
  • Hi, I am facing same problem. Can you help? Commented May 19, 2020 at 5:20

2 Answers 2

1

Some questions/suggestions that come to mind:

Is the linux server for development or production? I.e. Is there a HTTP server or just plain DJANGO running? (In the former case you don't start with "./manage runserver".)

"Then when I call up the website, it is shown correctly ..."

Is this because the port numbers different for the the requests? 40186 vs 60250.

You're getting a 404, e.g. url Not Found. This can be either the response of the HTTP server of from DJANGO.

Sign up to request clarification or add additional context in comments.

2 Comments

I am running this with runserver - but django-channels overrides the runserver command with its own (that starts daphne and the workers). The port might indeed be the issue - every failed request shows a different port - and those ports I cannot access. But I have no clue where those port numbers are coming from.
Actually the port numbers shown should be meaninless: as this request works: [2016/08/03 07:47:51] HTTP GET /static/css/style.css 200 [0.02, 127.0.0.1:53294] The problem seems to be that it handles an ws request as http
1

Can you post the complete log ?

Try running the server with daphne and run worker

daphne multichat.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2 
python manage.py runworker -v2 

Use something like supervisor to do this in a better way to restart these on failure.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.