Actioncable test if clients are connected on a channel

17 views
Skip to first unread message

Johan Smits

unread,
Feb 27, 2018, 3:43:05 AM2/27/18
to Ruby on Rails: Talk
Currently I have in my app I have cron tasks running that gather information and broadcasts it to the subscribers on the channels. On these taks I do view rendering before I broadcast the message to the client. But due to being a background cron task there is no user requesting the updated information and there might be no user listening to this broadcast and rendering is useless.
Therefore I'm looking (but could not find it in the documentation) if there is a way to check if there are clients listening on this channel/stream? It could save a lot of cpu. Now I send a very small message out and check the return value not 0 (means consumers are listening) but it should be more simple.
I could write code to track in the database if there are clients connected/disconnected on certain streams but the app already knows this (I assume?).
Reply all
Reply to author
Forward
0 new messages