2016-05-02 8 views
0

私は自分のlocalhostにActionCableを持つ作業用の5つのアプリを持っており、それをherokuにデプロイしようとしています。 チャットルームがあるページにアクセスすると、私はクロームのコンソールで見ることができます:ヘロクでActionCableをデプロイする(Rails 5 beta4)

WebSocket connection to 'wss://full-beyond-9816.herokuapp.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404 

私はセットアップRedisのとHerokuの上のRedisのアドオンをしました。ここに私のcable.ymlファイルの生産一部です:Herokuの上ActionCableを設定

(function() { 
    this.App || (this.App = {}); 

    App.cable = ActionCable.createConsumer(); 

}).call(this); 

はトリッキーなようで、私が見つけた全ての投稿:ここ

production: &production 
    :url: redis://redistogo:[email protected]:9463/ 
    :host: tarpon.redistogo.com 
    :port: 10272 
    :password: 12e348ac10ca002879ce7d85daf0bb0 
    :inline: true 
    :timeout: 1 

は私のroom.coffeeファイルです対象はPhusion Passenger(私はPumaを使用しています)か、かなり古いバージョンのActionCable(私はRails 5の最新ベータ版を使用しています)を使用しています。

これはどのように設定する必要がありますか? あなたの時間と助けてくれてありがとう

答えて

4

あなたの誤りからは分かりにくいです。 RedisアドオンとPumaを使ってHerokuにActionCableを導入しました。 ActionCableは新しくなって以来、私は認めなければならないが、サポートを得ることは難しい。私はそれを動作させるために周りを遊ばなければならなかった。

あなたの場合、おそらくコスの問題があります。ファイルの設定/環境/ production.rbを見て、次のセクションのコメントを解除して、Herokuのアプリ名を追加します。

# Action Cable endpoint configuration 
    config.action_cable.url = 'wss://yourappname.herokuapp.com/cable' 
    config.action_cable.allowed_request_origins = [ 'https://yourappname.herokuapp.com', /http:\/\/yourappname.herokuapp.com.*/ ] 

念のため、ここで私のcable.ymlファイル:また

# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket. 
production: 
    adapter: redis 
    url: add-hereyour-redis-url-from-heroku-redis-to-go-addon 

development: 
    adapter: async 

test: 
    adapter: async 

ドンAction Cableを実稼働させるためにRedisを追加することを忘れないでください。

#= require action_cable 
#= require_self 
#= require_tree . 

@App = {} 
App.cable = ActionCable.createConsumer() 
+0

おかげで、私は生産のラインを見ていない。そして、あなたのroom.coffeeファイルについて、FYI、それは単に(セットアップへのクライアント側のニーズ、この接続の消費者のインスタンスを意味する)のようになります。 .rb。今すぐ完璧に動作します! –

+0

私は助けてくれるとうれしいです:-) – doem

+0

cable.ymlでは、いくつかのerbを使うことができます: 'url:<%= ENV ['REDISTOGO_URL']%>' – cbedrosian

関連する問題