0

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.

4

1 回答 1

0

尝试使用以下内容安装 redis 插件。我的代码使用了这个:

电缆.yml

production:
    adapter: redis
    url: <%= ENV.fetch("REDISCLOUD_URL") { "redis://localhost:6379/1" } %>
    channel_prefix: _YourAppName_production

然后,在生产中安装(我的是在 heroku 上):

heroku addons:create rediscloud:30

而且我不需要 production.rb 中的 action_cable 设置,如果您保留 'myexample' 表达式原样,它将无法工作。

于 2020-05-19T00:06:23.563 回答