Channels - get online users

389 views
Skip to first unread message

Volodymyr Spodaryk

unread,
Mar 25, 2017, 1:35:34 PM3/25/17
to Django users
Hi,
is there any simple way to count online users that connected to Django Channels ?

Andrew Godwin

unread,
Mar 25, 2017, 7:46:28 PM3/25/17
to django...@googlegroups.com
Well, your problem is that you have to first define "online" and "users".

If you want "the number of open WebSockets connected to the system", then you can do it using logic tied to the connect and disconnect methods, with extra logic for expiry in case you miss a disconnect (otherwise the number will continuously creep up over time). There is no simple, scalable way, however.

If you're going to have strictly less than 100 websockets connected, and you're using the Redis backend, then group_channels() would give you an approximation of that number simply, but the performance drops off dramatically as you scale up a system. It will also include connections that are up to a day old (or however long your group_expiry is)

Andrew

On Sat, Mar 25, 2017 at 9:53 AM, Volodymyr Spodaryk <volodymyr...@gmail.com> wrote:
Hi,
is there any simple way to count online users that connected to Django Channels ?

--
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/d0acdec7-26e8-4889-bd41-5afe049b035a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shahab Emami

unread,
Mar 27, 2017, 3:05:01 PM3/27/17
to Django users
don't you have any sample project?
Reply all
Reply to author
Forward
0 new messages