动作电缆在生产环境中的导轨5.1.7中不起作用

问题描述 投票:0回答:1

我使用带导轨5.1.7的动作电缆,并且在本地开发环境和生产环境中都可以正常工作,但是将其部署在AWS 2上时却无法正常工作。以下是操作电缆配置的production.rb代码。

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

以及下面提到的cable.yml。

development:
  adapter: async

test:
  adapter: async

production:
  adapter: redis
  url: redis://localhost:6379/1

但是默认的安装路径get /cable没有在服务器配置级别上调用。如果我正在呼叫wss://example.com/cable,则表明它正在连接,但默认情况下页面加载时它没有连接。

ruby-on-rails actioncable ruby-on-rails-5.2 ruby-on-rails-5.1 redis-server
1个回答
0
投票

尝试安装以下内容的redis附加组件。我的代码与此::>

cable.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'表达式,它将不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.