Quantcast

Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

djangorobert
Hi hoping somebody in the entire Djang Users can help me solve this problem its been going on for about a week now Im using the django channels example on github the "Multichat" example I am using webfaction. 

my website for this test is www.openchat.us but when you go to the site it throws an error the error that i am getting is this: 
WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.


settings.py 

CHANNEL_LAYERS = {
   "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
        },
        "ROUTING": "myproject.routing.channel_routing",
   },
}




redis_host = os.environ.get('REDIS_HOST', 'localhost')


INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myproject',
    'channels',
    'chat',
]


command that im using to launch daphne is : daphne -p 24711 myproject.asgi:channel_layer

$ daphne -p 27411 myproject.asgi:channel_layer
2017-05-19 16:52:40,360 INFO     Starting server at tcp:port=27411:interface=127.0.0.1, channel layer myproject.asgi:channel_layer.
2017-05-19 16:52:40,360 INFO     HTTP/2 support enabled
2017-05-19 16:52:40,360 INFO     Using busy-loop synchronous mode on channel layer
2017-05-19 16:52:40,361 INFO     Listening on endpoint tcp:port=27411:interface=127.0.0.1

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/84199dbf-942d-43e4-9f08-098bc5cda922%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

djangorobert
One qustion i do have is do I leave it as localhost ? or do i change that to a different IP address or www.openchat.us ? thanks

On Friday, May 19, 2017 at 11:53:37 AM UTC-5, djangorobert wrote:
Hi hoping somebody in the entire Djang Users can help me solve this problem its been going on for about a week now Im using the django channels example on github the "Multichat" example I am using webfaction. 

my website for this test is <a href="http://www.openchat.us" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8ntpNENwvZ3RdcBt5OTUPzFJQlA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8ntpNENwvZ3RdcBt5OTUPzFJQlA&#39;;return true;">www.openchat.us but when you go to the site it throws an error the error that i am getting is this: 
WebSocket connection to 'ws://<a href="http://openchat.us:24711/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fopenchat.us%3A24711%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2qSVKzG_vjmLBaK5P_7JdbLABdA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fopenchat.us%3A24711%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2qSVKzG_vjmLBaK5P_7JdbLABdA&#39;;return true;">openchat.us:24711/' failed: WebSocket is closed before the connection is established.


settings.py 

CHANNEL_LAYERS = {
   "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
        },
        "ROUTING": "myproject.routing.channel_routing",
   },
}




redis_host = os.environ.get('REDIS_HOST', 'localhost')


INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myproject',
    'channels',
    'chat',
]


command that im using to launch daphne is : daphne -p 24711 myproject.asgi:channel_layer

$ daphne -p 27411 myproject.asgi:channel_layer
2017-05-19 16:52:40,360 INFO     Starting server at tcp:port=27411:interface=127.0.0.1, channel layer myproject.asgi:channel_layer.
2017-05-19 16:52:40,360 INFO     HTTP/2 support enabled
2017-05-19 16:52:40,360 INFO     Using busy-loop synchronous mode on channel layer
2017-05-19 16:52:40,361 INFO     Listening on endpoint tcp:port=27411:interface=127.0.0.1

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/6abd0b3f-f1c8-4661-804b-b69c6598bc35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

djangorobert
In reply to this post by djangorobert

    var connect = function () {
        log('connect');
        var oldWs = ws;
        ws = new config.constructor(url, protocols);

thats part of what the error points me to in google tools: 




(index):182 Disconnected from chat socket
VM170 websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Invalid status line
connect @ VM170 websocketbridge.js:118
(index):182 Disconnected from chat socket
On Friday, May 19, 2017 at 11:53:37 AM UTC-5, djangorobert wrote:
Hi hoping somebody in the entire Djang Users can help me solve this problem its been going on for about a week now Im using the django channels example on github the "Multichat" example I am using webfaction. 

my website for this test is <a href="http://www.openchat.us" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8ntpNENwvZ3RdcBt5OTUPzFJQlA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8ntpNENwvZ3RdcBt5OTUPzFJQlA&#39;;return true;">www.openchat.us but when you go to the site it throws an error the error that i am getting is this: 
WebSocket connection to 'ws://<a href="http://openchat.us:24711/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fopenchat.us%3A24711%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2qSVKzG_vjmLBaK5P_7JdbLABdA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fopenchat.us%3A24711%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2qSVKzG_vjmLBaK5P_7JdbLABdA&#39;;return true;">openchat.us:24711/' failed: WebSocket is closed before the connection is established.


settings.py 

CHANNEL_LAYERS = {
   "default": {
        "BACKEND": "asgi_redis.RedisChannelLayer",
        "CONFIG": {
        },
        "ROUTING": "myproject.routing.channel_routing",
   },
}




redis_host = os.environ.get('REDIS_HOST', 'localhost')


INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myproject',
    'channels',
    'chat',
]


command that im using to launch daphne is : daphne -p 24711 myproject.asgi:channel_layer

$ daphne -p 27411 myproject.asgi:channel_layer
2017-05-19 16:52:40,360 INFO     Starting server at tcp:port=27411:interface=127.0.0.1, channel layer myproject.asgi:channel_layer.
2017-05-19 16:52:40,360 INFO     HTTP/2 support enabled
2017-05-19 16:52:40,360 INFO     Using busy-loop synchronous mode on channel layer
2017-05-19 16:52:40,361 INFO     Listening on endpoint tcp:port=27411:interface=127.0.0.1

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/cc6b6004-0947-4aca-9a5b-704b967538e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

James Schneider


On May 19, 2017 8:02 PM, "djangorobert" <[hidden email]> wrote:

    var connect = function () {
        log('connect');
        var oldWs = ws;
        ws = new config.constructor(url, protocols);

thats part of what the error points me to in google tools: 




(index):182 Disconnected from chat socket
VM170 websocketbridge.js:118 WebSocket connection to 'ws://www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Invalid status line
connect @ VM170 websocketbridge.js:118
(index):182 Disconnected from chat socket
On Friday, May 19, 2017 at 11:53:37 AM UTC-5, 


Not sure if Web sockets have this problem, but I've seen invalid handshake errors come about when one side is using HTTPS and the other is just using HTTP. Perhaps connect to wss:// instead of ws://? I think that's the secure protocol for web sockets.

-James

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/CA%2Be%2BciVs9kDEzAChJ_vC60w2jqii%2Bi25kF-evsVUq65hA0W_-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

djangorobert
Thanks james going to try it out will post my results in a bit thank you for your time its appreciated.

On Friday, May 19, 2017 at 11:21:33 PM UTC-5, James Schneider wrote:


On May 19, 2017 8:02 PM, "djangorobert" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OMvUAIBZAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">djangoc...@...> wrote:

    var connect = function () {
        log('connect');
        var oldWs = ws;
        ws = new config.constructor(url, protocols);

thats part of what the error points me to in google tools: 




(index):182 Disconnected from chat socket
VM170 websocketbridge.js:118 WebSocket connection to 'ws://<a href="http://www.openchat.us/chat/stream/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us%2Fchat%2Fstream%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGe6ryLG7jZSlM-NuSBbPyraF3LnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us%2Fchat%2Fstream%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGe6ryLG7jZSlM-NuSBbPyraF3LnQ&#39;;return true;">www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Invalid status line
connect @ VM170 websocketbridge.js:118
(index):182 Disconnected from chat socket
On Friday, May 19, 2017 at 11:53:37 AM UTC-5, 


Not sure if Web sockets have this problem, but I've seen invalid handshake errors come about when one side is using HTTPS and the other is just using HTTP. Perhaps connect to wss:// instead of ws://? I think that's the secure protocol for web sockets.

-James

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/b018828e-e45f-4040-b0a1-9909d5e1a789%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

djangorobert
In reply to this post by James Schneider
hi james im going off of andrew godwins django channels example on github the multi chat example and using Webfactions hosting services. 
im  getting the error of the websocket being closed
I know your saying to maybe chaning it to wss instead of ws do you mean to change it in the javascript that is in the django channels github for multichat js file ?

On Friday, May 19, 2017 at 11:21:33 PM UTC-5, James Schneider wrote:


On May 19, 2017 8:02 PM, "djangorobert" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OMvUAIBZAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">djangoc...@...> wrote:

    var connect = function () {
        log('connect');
        var oldWs = ws;
        ws = new config.constructor(url, protocols);

thats part of what the error points me to in google tools: 




(index):182 Disconnected from chat socket
VM170 websocketbridge.js:118 WebSocket connection to 'ws://<a href="http://www.openchat.us/chat/stream/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us%2Fchat%2Fstream%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGe6ryLG7jZSlM-NuSBbPyraF3LnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.openchat.us%2Fchat%2Fstream%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGe6ryLG7jZSlM-NuSBbPyraF3LnQ&#39;;return true;">www.openchat.us/chat/stream/' failed: Error during WebSocket handshake: Invalid status line
connect @ VM170 websocketbridge.js:118
(index):182 Disconnected from chat socket
On Friday, May 19, 2017 at 11:53:37 AM UTC-5, 


Not sure if Web sockets have this problem, but I've seen invalid handshake errors come about when one side is using HTTPS and the other is just using HTTP. Perhaps connect to wss:// instead of ws://? I think that's the secure protocol for web sockets.

-James

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/c4eb889f-c0da-4f6c-9f08-8bfee0ef841d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django Channels Error: WebSocket connection to 'ws://openchat.us:24711/' failed: WebSocket is closed before the connection is established.

James Schneider


On May 20, 2017 8:33 PM, "djangorobert" <[hidden email]> wrote:
hi james im going off of andrew godwins django channels example on github the multi chat example and using Webfactions hosting services. 
im  getting the error of the websocket being closed
I know your saying to maybe chaning it to wss instead of ws do you mean to change it in the javascript that is in the django channels github for multichat js file ?

TBH, I have no idea. I've never worked with channels. I was speaking more from a broader web application experience and typical HTTP calls.

I highly doubt any code changes in the actual library are needed.

Does the Django runserver console  notice the incoming connection? It may provide a clue or traceback. A brief overview of the docs indicates that the Django processes proxies the connection to the channels workers, do is imagine something would come up there. Beyond that I can't be much help.

-James

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/CA%2Be%2BciVNsdNb5znVMrM19egcoN0QK2uSubVcAXnXG0waHY94Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...