Deploying Rails ActionCable using AWS Elastic Beanstalk

淺唱寂寞╮ 提交于 2019-12-12 12:37:29

问题


I'm trying to deploy the chat demo from DHH on AWS Elastic Beanstalk. I've followed the tutorial here: https://keithpblog.wordpress.com/2015/12/30/rails-5-tutorial-chat-app-can-we-deploy-it And I've managed to get the solution deployed in a single instance and Redis up and running too. But when I try to post something, the message is saved in the db, but not returned by the WebSocket. I've checked the production.log and I can see this error message:

E, [2016-05-20T20:33:52.676577 #24281] ERROR -- : There was an exception - Gem::LoadError(Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded. Add gem 'redis' to your Gemfile (and ensure its version is at the minimum required by Action Cable).)

E, [2016-05-20T20:33:52.676826 #24281] ERROR -- : /opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:37:in `rescue in pubsub_adapter'

/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/actioncable-5.0.0.rc1/lib/action_cable/server/configuration.rb:34:in `pubsub_adapter'

I also have in my Gemfile: gem 'redis', '~>3.2'

Any Ideas? Thanks!


回答1:


I fixed the error by adding to my Gemfile:

gem 'em-hiredis'
gem 'redis'

The other change that I had to make was on /environments/production.rb

config.action_cable.url = 'ws://url.com/cable'
config.action_cable.allowed_request_origins = ['http://url.com']

And with that, I have actioncable up and running on Elastic Beanstalk



来源:https://stackoverflow.com/questions/37356503/deploying-rails-actioncable-using-aws-elastic-beanstalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!