I using action cable with rails 5.1.7 and it's working fine in development env and production env on locally but when it's deployed on aws ec2 it's not working. Below is the production.rb code for action cable config.
config.action_cable.url = 'wss://example.com/cable'
config.action_cable.allowed_request_origins = ["https://example.com", "https://www.example.com"]
config.action_cable.mount_path = '/cable/:token'
ActionCable.server.config.disable_request_forgery_protection = true
And cable.yml is mentioned below.
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
but the default mounted path get /cable
not calling at the server config level. If I'm calling wss://example.com/cable then it's connecting but default on page load it's not connecting.
Try to install the redis add-on, with the following. My code worked with this:
cable.yml
production:
adapter: redis
url: <%= ENV.fetch("REDISCLOUD_URL") { "redis://localhost:6379/1" } %>
channel_prefix: _YourAppName_production
then, to install on production (mine was on heroku):
heroku addons:create rediscloud:30
and I didn't need the action_cable setups in production.rb, it won't work if you leave 'myexample' expression as it is.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.