channels: Websocket connection failed in production

Hello,

I try to use Django Channels on my website developed with Django 1.10 and Python 3.5. This website is hosted on Webfaction. My problem is about the socket, the connection doesn’t works, I have this error when I go to the home page of the website :

WebSocket connection to ‘ws://mywebsite.com/’ failed: Error during WebSocket handshake: Unexpected response code: 200 Disconnected from chat socket

I created the websocket in a Javascript file :

var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws";
var ws_path = ws_scheme + '://' + window.location.host + window.location.pathname;					
var socket = new WebSocket(ws_path);

I have already configure Redis server and it works :

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 111111)],
        },
	"ROUTING": "projup.routing.channel_routing",
    },
}

111111 is the port number of an application.

My ALLOWED_HOST configuration is :

ALLOWED_HOSTS = [
        '.mywebsite.com',
        '.mywebsite.net',
]

I don’t have error logs.

How can I resolve this problem (websocket connection impossible) ? Do you need a new app/port for the websocket ? Should I use the port of my website ? How ? Do you need to run a command that would start listening on a port ?

Thank you ! 😃

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (4 by maintainers)

Most upvoted comments

Lol will do

On May 22, 2017 1:28 PM, “Andrew Godwin” notifications@github.com wrote:

@djangorobert https://github.com/djangorobert The issue comments aren’t for user help - please keep to the django-users mailing list, thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/django/channels/issues/445#issuecomment-303182122, or mute the thread https://github.com/notifications/unsubscribe-auth/ARSyoNIMF5get6c9hlgQsbNZaL254Orwks5r8dPegaJpZM4LDqtf .