Channels websocket disconnecting after ~1min

18 views
Skip to first unread message

Ahmed Magdy

unread,
Feb 4, 2018, 6:49:45 PM2/4/18
to Django users
Hello, and sorry for lots of questions about channels.

I can connect to the websocket from JavaScript and send/receive normally for exactly 60~61sec after that the HTTP request is repeated on it's own and the websocket disconnects.
Sometimes the HTTP get request is repeated more than once before the websocket disconnection.

Even just connecting and waiting for 60~61secs result in the same thing.

Terminal log

Django version 2.0.2, using settings 'husite.settings'
Starting ASGI/Channels development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
2018-02-05 01:35:22,350 - INFO - server - HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2018-02-05 01:35:22,351 - INFO - server - Listening on endpoint tcp:port=8000:interface=127.0.0.1
[2018/02/05 01:35:27] HTTP GET /sessions/24/ 200 [0.05, 127.0.0.1:9066]
[2018/02/05 01:35:27] WebSocket HANDSHAKING /sessions/24 [127.0.0.1:9067]
[2018/02/05 01:35:27] WebSocket CONNECT /sessions/24 [127.0.0.1:9067]
[2018/02/05 01:36:28] HTTP GET /sessions/24 503 [61.05, 127.0.0.1:9067]
[2018/02/05 01:36:28] WebSocket DISCONNECT /sessions/24 [127.0.0.1:9067]

# settings.py
# ...
ASGI_APPLICATION = "husite.routing.application"
CHANNEL_LAYERS = {
   "default": {
       "BACKEND": "channels_redis.core.RedisChannelLayer",
       "CONFIG": {
           "hosts": [("localhost", 6379)],
       },
   },
}

class MyConsumer(WebsocketConsumer):
   def connect(self):
       self.accept()

// Javascript code
ws = new WebSocket(`${protocol}://${location.host}/sessions/{{session.id}}`)


Andrew Godwin

unread,
Feb 4, 2018, 6:59:45 PM2/4/18
to django...@googlegroups.com
Hi there,

This is a bug that should be fixed in the latest release of Daphne that I put out a few hours ago.

Andrew

--
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...@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/63f72d2c-c5b7-4729-9d85-d4b1bcbe7e6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmed Magdy

unread,
Feb 4, 2018, 8:47:30 PM2/4/18
to Django users
Thanks!

I don't know if it was on purpose but you forgot to update the pypi package.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Andrew Godwin

unread,
Feb 4, 2018, 8:50:15 PM2/4/18
to django...@googlegroups.com
That would be me trying to move deployment to Travis. I'll push it up now.

Andrew

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...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages