Monday, December 5, 2016

Re: Websocket connection failed in production with Django-Channels

For future reference, this discussion is also happening here: https://github.com/django/channels/issues/445

On Mon, Dec 5, 2016 at 2:04 AM, yass45 <bouslim.yass@gmail.com> wrote:

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 ! :)

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/12f8dea7-e32e-4c31-9269-0553f221ae10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAFwN1uqN%3DoqVM1RJPGk_dh4LLYXiPbZf9G9F3-X4bwrvDgLvHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment