Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

Matt Taylor asked in Rails

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

Reply

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.

Reply

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

Reply

Computers eh? :)

Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.