All threads / How to Deploy ActionCable and Rails 5 To Production Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to Deploy ActionCable and Rails 5 To Production Discussion

Hongli Lai ·

Nice! This is pretty much what we also recommend in our upcoming Action Cable integration documentation.

One thing that I'd like to add is that you will need to configure config/cable.yml to specify either redis or postgresql as adapter. Rails 5 is going to default to the in-process 'async' adapter, but that adapter does not work when multiple processes are involved (as is the case with Passenger).

I forgot about that until after I finished recording! The actioncable-examples repository that I cloned still used the Redis adapter default, so I totally overlooked that change. Great to know.

@honglilai:disqus @excid3:disqus so, does that mean if we are not specifying either redis or postgresql as adapter, the chat message couldn't be saved into our app database?

Hongli Lai ·

The chat message would still be saved, but the notification wouldn't be broadcasted to all the clients connected to the WebSocket.

Sahand Sehatpour ·

what does it mean to use postgres as adapter?

Reply

Thanks Chris for this great tutorial! I've 2 questions:

1. Can we use this setup on Heroku?

2. Currently, I'm using Puma server on Heroku which only allow 16 concurrent connection at a time https://devcenter.heroku.co...

My question, if we use Passenger, can we get the 'unlimited' concurrent connection?

I'm going to be doing some testing on Heroku to see, but I think you'll be fine using Puma on there still.

Did you ever do any testing with Heroku?

I haven't yet, was hoping that the first release candidate would ship, but still waiting on that. I put these episodes out and then like the next week a bunch changed so I didn't want to be making too many immediately outdated episodes.

Yeah. That makes sense. I'm finding several different tutorials teaching different ways of getting ActionCable to work.

Good news! Heroku is actually really easy now.

Just tested it this morning and it's super easy to setup: https://github.com/excid3/a...

The trick is that you _must_ use the route mounted version because Heroku apps only expose one port. Just make sure you have a Redis connection added, and you should be all set.

You can try out my example app here: http://actioncable-gorails.... (just make sure you're on http, not https.

Could you please make one screencast on actioncable on heroku with all deployment options, e.g., Thin, Unicorn, Puma, Passenger etc.? Also, what would be your recommended set up? For instance, is Postgres on Heroku is sufficient or should we also deploy Redis?

Hi Chris. I looked at your github and implemented your setup. I'm still not getting it to work.

I'm using both Heroku postgres and Heroku Redis on the same app. Is that the correct way of doing it?

Reply

Thanks, I just successfully deploy to passenger and Pg as backend, my chat repository is https://github.com/Eric-Guo...

Reply
Black Disc ·

Great Tutorial. Chris, can you use a larger font while recording the screencast. The small font is hard to read. Thanks

Reply
Dinesh Atoliya ·

Nice tutorial! I am trying send notification if a logged in user get invited. Any idea, how do I track if a user is logged in or not ? Any hint or help would be great.

Reply

Hi, So I am trying to deploy an app that has actioncable on heroku. However, I don't have the index.coffee file in javascripts since I have used the js file instead like on the group chat with action cable series on here.
How do I go about deploying my app on heroku, knowing that it has actioncable?
Thank you!

I don't believe there are any necessary changes for Heroku. You should be able to just deploy it, making sure that your allowed request origins match the domain you're running on.

I deployed it on heroku, everything works well but the actioncable. The messages sent are not displaying. When I run the heroku console on terminal, the Message.all is empty as well. What do you think the problem may be?

Reply
Diogo Wernik ·

Could not make it work!

Set: index.coffee, route.rb, development.rb and production.rb , set nginx with and without pasenger and get the same error!

WebSocket connection to 'ws://example.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

Could some one help me?

Reply

I got the same problem with Diogo Wernick. I got this error:

WebSocket connection to 'ws://example.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

And also when I open production.log on the server, I see this error:

WebSocket error occurred: One or more reserved bits are on: reserved1 = 1, reserved2 = 0, reserved3 = 0

Here is the link to the thread which has more details:
https://gorails.com/forum/websockets-with-rails-passenger-error-during-websocket-handshake-unexpected-response-code-400

Please help.

Reply
Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.