Skip to main content

How do I debug why my ActionCable broadcast is returning nil?

Rails • Asked by Matt Taylor

Following along with the ActionCable Series.

So in irb when i run the ActionCable.server.broadcast "notifications:4", {html: "<div>Hello</div>"} it comes back with nil instead of returning 1. Looking in my server logs I see:

NotificationsChannel is transmitting the subscription confirmation
NotificationsChannel is streaming from notifications:4

any idea why that would be returning nil?
Not sure where to look to see error message. redis cli?

Thanks


First, I'd check to make sure your cable.yml defines using redis in development so that it can be shared between processes. Second, if you run redis-cli you can say subscribe notifications:4 to have the redis cli show you the messages coming across there as well.

If you send a message on the channel, then it should show up in the redis cli. If it doesn't, you've narrowed it down to probably a configuration problem there and can debug why the message doesn't make it to redis. If it does, then you'll want to debug the client side to figure out why things aren't getting relayed to the websocket as you're expecting.


That is wierd.... Loaded it back up and now it works. Not sure. Maybe a server restart or something I needed to do.

Thanks Chris


Computers eh? :)


Yeah, I remember restarting everything, but yes, computers can be fickle.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.