Stack for implementing a real-time app with Rails5

Hello @justin and everyone!

It’s been quite a while since I visit the forum last time. :wink:

Since Rails 5 is out, making a real-time app expected to be easier with actioncables…

But, I’m still feeling like I will need to use additional stack if you want to make a more efficient realtime app with rails 5.

Would like to know what combination of stack is preferable with Rails 5.

Aloha @askar!

Since Rails 5 is out, making a real-time app expected to be easier with actioncables…

We have a demo of this live at https://www.reactrails.com/

But, I’m still feeling like I will need to use additional stack if you want to make a more efficient realtime app with rails 5.

Not sure what you mean.

Hi Justin.

Just checked the demo. It’s just a SPA. Do you have any demo with action cable implemented?

The link I gave you uses action cable: https://www.reactrails.com/.

You can see the source code here: https://github.com/shakacode/react-webpack-rails-tutorial.

Does that answer your question?

I opened https://www.reactrails.com/ in two browsers.
When I posted a comment, it didn’t updated automatically on the other browser…
I meant a realtime update.

There’s some bug. This used to work…

Please try to install locally and give it a try.

Maybe there is a problem with our heroku config.

Thanks, Jason.

Locally, it was working same way (non-realtime update) with the log output:

13:02:55 rails.1               | Started GET "/cable" for 127.0.0.1 at 2017-02-15 13:02:55 +0900
13:02:55 rails.1               | Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2017-02-15 13:02:55 +0900
13:02:55 rails.1               | Request origin not allowed: http://localhost:5000
13:02:55 rails.1               | Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
13:02:55 rails.1               | Finished "/cable/" [WebSocket] for 127.0.0.1 at 2017-02-15 13:02:55 +0900

But I had it working with 2 things:

  1. Added config.action_cable.allowed_request_origins = ['http://localhost:5000'] in development.rb as rails server was running on port 5000 (Ref: http://stackoverflow.com/a/35442353/1745902)

  2. Then I started redis-server, as it was then giving error Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)

I’m wondering if heroku app is having same error Request origin not allowed ?

Fixed in https://github.com/shakacode/react-webpack-rails-tutorial/pull/360.

Live right now!

If you like, review the PR and give me the :thumbsup:.

1 Like

Thanks, Justin. Done :slight_smile: