1

Last week I was working through a chat app tutorial that guided me through using Redis for a turbo stream. But then I stumbled across DHH's demo of Rails 7 where he hooks up the broadcast simply using Rails out of the box.

Now, when I try to follow his approach, I get this error in the server output:

Error performing Turbo::Streams::ActionBroadcast (lots of numbers) Redis::CannotConnectError 

I think the problem is that my turbo stream is configured to use Redis since I installed it last week. So what I'm hoping to be able to do is to revert to the turbo configuration that comes built in to Rails 7. I'd love to bypass Redis if possible, since this approach seems cleaner. Not to mention, with last week's chat app, I never managed to get Redis working after deploying to Heroku (but I did get it working in development).

I thought about uninstalling Redis, but I don't think that would change the turbo configuration anyway. And I'm worried leave me in a spot that's even trickier to fix.

Any insight is appreciated.

Edit: After a bit more research, Redis seems to come in the standard gemfile in Rails 7. I was able to clear this error by starting my Redis server. But DHH never does that in the demo video. Also, my views are still not updating live.

Jeff Zivkovic
  • 547
  • 1
  • 4
  • 20
  • 1
    If you don't use Redis then the stream is inline: it comes straight from the server to you only. In order to update other users browsers you have to Broadcast (Actioncable i.e. Websockets). If it doesn't work, check for any error in the code. To debug websockets you have to open the developper tools in your browser. – Maxence Aug 24 '22 at 22:48
  • 1
    But now I'm a little confused as to how DHH gets his turbo stream working simply by setting up his importmap, adding a stream div in his view, and then a broadcast in his model. He gets two browsers updating live without ever mentioning Redis. – Jeff Zivkovic Aug 26 '22 at 17:42
  • https://youtu.be/mpWFrUwAN88 – Jeff Zivkovic Aug 26 '22 at 17:42
  • 1
    Redis is not the only adapter. When I set up a new Rails app I add Redis by default. But Rails may come preset with :async https://stackoverflow.com/questions/39948416/what-is-ruby-on-rails-action-cable-adapter Yet Redis is a free software and is much much better than any other Rails adapter. It is an actual lightweight key/value database. Maybe you get this error because you have asked Rails to use Redis but didn't install it. Use :async and check again. – Maxence Aug 30 '22 at 20:08

0 Answers0