20361
以下のリンクを参考にlocalではrails5のチャットアプリを作成できました。  
<http://qiita.com/jnchito/items/aec75fab42804287d71b>

herokuでも動作させようと思いいろいろやってみましたがうまくいきません。  
1日かかっても検討がつかない為質問させていただきました。  
何か助言をいただけないでしょうか。

herokuで追加でやったことは  
・rediscloudをアドオンで追加  
・/config/redis/cable.yml のproduction:urlをENV["REDISCLOUD_URL"]に変更（なんとなく）

chromeのnetworkでは以下のようなエラー

> WebSocket connection to 'wss://rails5chatxxxx.herokuapp.com/cable' failed:  
>  WebSocket is closed before the connection is established.

herokuのlogでは  
アプリ起動時

> 2015-12-23T05:24:32.308667+00:00 app[web.1]: => Booting Puma  
>  2015-12-23T05:24:32.308689+00:00 app[web.1]: => Rails 5.0.0.beta1
> application starting in production on ttp://0.0.0.0:43766  
>  2015-12-23T05:24:32.308690+00:00 app[web.1]: => Run `rails server -h` for
> more startup options  
>  2015-12-23T05:24:32.308691+00:00 app[web.1]: => Ctrl-C to shutdown server  
>  2015-12-23T05:24:32.380698+00:00 app[web.1]: DEPRECATION WARNING:
> `serve_static_files` is deprecated and will be removed in Rails 5.1.  
>  2015-12-23T05:24:32.380702+00:00 app[web.1]: Please use
> `public_file_server.enabled = true` instead.  
>  2015-12-23T05:24:32.380703+00:00 app[web.1]: (called from block in
> tsort_each at /app/vendor/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228)  
>  2015-12-23T05:24:32.864256+00:00 app[worker.1]: rake aborted!  
>  2015-12-23T05:24:32.864271+00:00 app[worker.1]: Don't know how to build
> task 'jobs:work'  
>  2015-12-23T05:24:32.864445+00:00 app[worker.1]:  
>  2015-12-23T05:24:32.864465+00:00 app[worker.1]: (See full trace by running
> task with --trace)  
>  2015-12-23T05:24:33.073776+00:00 heroku[web.1]: Process exited with status
> 143  
>  2015-12-23T05:24:33.050125+00:00 app[web.1]: Puma 2.15.3 starting...  
>  2015-12-23T05:24:33.050130+00:00 app[web.1]: * Min threads: 0, max threads:
> 16  
>  2015-12-23T05:24:33.050131+00:00 app[web.1]: * Environment: production  
>  2015-12-23T05:24:33.050132+00:00 app[web.1]: * Listening on
> tcp://0.0.0.0:43766  
>  2015-12-23T05:24:33.598097+00:00 heroku[worker.1]: State changed from up to
> crashed  
>  2015-12-23T05:24:33.577983+00:00 heroku[worker.1]: Process exited with
> status 1

その後以下の様なログが繰り返されます

> 2015-12-23T05:31:46.633164+00:00 heroku[router]: at=error code=H12
> desc="Request timeout" method=GET path="/cable"
> host=rails5chatxxxx.herokuapp.com
> request_id=00ff5924-89b8-4fbc-b738-4ffa0bf84981 fwd="119.83.217.68"
> dyno=web.1 connect=1ms service=30001ms status=503 bytes=0  
>  2015-12-23T05:32:07.671155+00:00 heroku[router]: at=error code=H12
> desc="Request timeout" method=GET path="/cable"
> host=rails5chat.herokuapp.com
> request_id=b925dc28-e0b4-40ac-b0e2-79a4f142e6b0 fwd="119.83.217.68"
> dyno=web.1 connect=1ms service=30001ms status=503 bytes=0  
>  2015-12-23T05:32:11.828813+00:00 app[web.1]: Started GET "/cable" for
> 119.83.217.68 at 2015-12-23 05:32:11 +0000  
>  2015-12-23T05:32:11.831413+00:00 app[web.1]: Started GET "/cable/"
> [WebSocket] for 119.83.217.68 at 2015-12-23 05:32:11 +0000  
>  2015-12-23T05:32:11.831491+00:00 app[web.1]: Request origin not allowed:
> ttps://rails5chatxxxx.herokuapp.com  
>  2015-12-23T05:32:11.831555+00:00 app[web.1]: Finished "/cable/" [WebSocket]
> for 119.83.217.68 at 2015-12-23 05:32:11 +0000  
>  2015-12-23T05:32:15.689969+00:00 app[web.1]: Started GET "/cable" for
> 119.83.217.68 at 2015-12-23 05:32:15 +0000  
>  2015-12-23T05:32:15.693371+00:00 app[web.1]: Started GET "/cable/"
> [WebSocket] for 119.83.217.68 at 2015-12-23 05:32:15 +0000  
>  2015-12-23T05:32:15.693418+00:00 app[web.1]: Request origin not allowed:
> ttps://rails5chatxxxx.herokuapp.com  
>  2015-12-23T05:32:15.693490+00:00 app[web.1]: Finished "/cable/" [WebSocket]
> for 119.83.217.68 at 2015-12-23 05:32:15 +0000  
>  2015-12-23T05:32:16.353150+00:00 heroku[router]: at=error code=H12
> desc="Request timeout" method=GET path="/cable"
> host=rails5chatxxxx.herokuapp.com
> request_id=56c96769-e94b-49f2-bd45-d69fdb850058 fwd="119.83.217.68"
> dyno=web.1 connect=15ms service=30000ms status=503 bytes=0  
>  2015-12-23T05:32:38.642087+00:00 app[web.1]: Started GET "/cable" for
> 119.83.217.68 at 2015-12-23 05:32:38 +0000  
>  2015-12-23T05:32:38.644988+00:00 app[web.1]: Started GET "/cable/"
> [WebSocket] for 119.83.217.68 at 2015-12-23 05:32:38 +0000  
>  2015-12-23T05:32:38.645033+00:00 app[web.1]: Request origin not allowed:
> ttps://rails5chatxxxx.herokuapp.com  
>  2015-12-23T05:32:38.645078+00:00 app[web.1]: Finished "/cable/" [WebSocket]
> for 119.83.217.68 at 2015-12-23 05:32:38 +0000  
>  2015-12-23T05:32:41.832172+00:00 heroku[router]: at=error code=H12
> desc="Request timeout" method=GET path="/cable"
> host=rails5chatxxxx.herokuapp.com
> request_id=7027966d-1bf0-4624-ba92-1177c570a622 fwd="119.83.217.68"
> dyno=web.1 connect=0ms service=30001ms status=503 bytes=0  
>  2015-12-23T05:32:45.285005+00:00 app[web.1]: Started GET "/cable" for
> 119.83.217.68 at 2015-12-23 05:32:45 +0000  
>  2015-12-23T05:32:45.287925+00:00 app[web.1]: Started GET "/cable/"
> [WebSocket] for 119.83.217.68 at 2015-12-23 05:32:45 +0000  
>  2015-12-23T05:32:45.287980+00:00 app[web.1]: Request origin not allowed:
> ttps://rails5chatxxxx.herokuapp.com  
>  2015-12-23T05:32:45.288046+00:00 app[web.1]: Finished "/cable/" [WebSocket]
> for 119.83.217.68 at 2015-12-23 05:32:45 +0000  
>  2015-12-23T05:32:45.717113+00:00 heroku[router]: at=error code=H12
> desc="Request timeout" method=GET path="/cable"
> host=rails5chatxxxx.herokuapp.com
> request_id=8ef144f2-f5f4-4e2a-9ae2-0ca015df58f5 fwd="119.83.217.68"
> dyno=web.1 connect=0ms service=30000ms status=503 bytes=0

※httpをttpに変更してあります。
CC BY-SA 3.0
2015-12-23T06:20:31.727
20308
2015-12-25T07:39:36.560
13774
question
ruby-on-rails heroku websocket
herokuでrails5のチャットアプリの公開
リモートで動かす時には、Action CableがWebSocketの接続元の制限をしているようです (`Request origin not
allowed`)。当方では、[`config/environments/production.rb`で`config.action_cable.allowed_request_origins`を設定する](https://github.com/JunichiIto/campfire/commit/4b4e726f2b541d0f43ae019c6fc121df6f8fbc02)ことでチャットができるようになりました。
CC BY-SA 3.0
2015-12-25T07:39:36.560
20361
2015-12-25T07:39:36.560
13807
20308
answer