4

我的 rails(5.0.0beta4)(和 actioncable)在本地运行良好。

但是在 heroku 上,浏览器似乎没有从 actioncable 流中接收任何数据。

这是我的heroku设置:

我正在使用 redis-to-go 插件

production: &production
  adapter: redis
  url: redis://redistogo:[password]@hoki.redistogo.com:9079/
  host: hoki.redistogo.com
  port: 9079
  password: [password]
  inline: true
  timeout: 10

config/environments/production.rb

config.action_cable.url = "https://duewiz.herokuapp.com/cable"
config.action_cable.allowed_request_origins = ["https://duewiz.herokuapp.com",/http:\/\/duewiz.herokuapp.com.*/]

在这里,我尝试了 wss 和 https 协议,但都不起作用。

routes.rb mount ActionCable.server => '/cable'

而在app/assets/javascripts/channels/cable.coffee.erb

#= require action_cable
#= require_self
#= require_tree .
#
@App ||= {}
App.cable = ActionCable.createConsumer()

redis-cli monitor在 redis-to-go 服务器上运行,它打印出我ActionCable.broadcast调用的数据

在heroku日志中,我可以看到ActionCable广播

但我在浏览器中看不到任何变化,但在本地一切正常。

我已经heroku restart为每个部署运行

我还记得我使用 devise/warden 进行身份验证的一件事(也用于 actioncable)

module ApplicationCable
    class Connection < ActionCable::Connection::Base
      identified_by :current_user

        def connect
          self.current_user = find_verified_user
          logger.add_tags 'ActionCable', current_user.email
        end

      protected
        def find_verified_user
          if verified_user = User.find_by(id: cookies.signed['user.id'])
            verified_user
          else
            reject_unauthorized_connection
          end
        end
    end
end

那么我应该如何配置 actioncable 以在 heroku 上进行部署?

感谢帮助。


感谢 pdoherty926。我的浏览器控制台中没有 javascript 错误。

4

0 回答 0