0

我正在尝试在 heroku 上的 rails 5 应用程序上部署 reactjs 这是我的 Procfile

web: bundle exec puma -C config/puma.rb

这是我的 puma.rb 文件

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 5000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

这是我的 cable.yml 文件

production:
:url: redis://redistogo:f9e8821e7e25167ae7023516bd3fce13@tarpon.redistogo.com:11879/
:host: tarpon.redistogo.com
:port: 11879
:password: xxxx
:inline: true
:timeout: 1

development:
  url: redis://localhost:6379/2

test:
  url: redis://localhost:6379/3

我尝试使用从 reactjs 连接到套接字

App.cable = ActionCable.createConsumer("wss://adham-chatty.heroku.com");

但我在 chrome 控制台上有这个错误,并且套接字不工作:\

WebSocket connection to 'wss://adham-chatty.heroku.com/' failed: WebSocket opening handshake was canceled

这是我的 Heroku 日志

016-01-19T17:17:22.405051+00:00 heroku[web.1]: State changed from up to starting
    2016-01-19T17:17:25.031404+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
    2016-01-19T17:17:26.521202+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2016-01-19T17:17:27.266810+00:00 app[web.1]: [3] Puma starting in cluster mode...
    2016-01-19T17:17:27.266821+00:00 app[web.1]: [3] * Version 2.15.3 (ruby 2.2.2-p95), codename: Autumn Arbor Airbrush
    2016-01-19T17:17:27.266822+00:00 app[web.1]: [3] * Min threads: 5, max threads: 5
    2016-01-19T17:17:27.266822+00:00 app[web.1]: [3] * Environment: production
    2016-01-19T17:17:27.266823+00:00 app[web.1]: [3] * Process workers: 2
    2016-01-19T17:17:27.266823+00:00 app[web.1]: [3] * Preloading application
    2016-01-19T17:17:27.721211+00:00 app[web.1]: [3] - Gracefully shutting down workers...
    2016-01-19T17:17:28.101087+00:00 app[web.1]: [3] === puma shutdown: 2016-01-19 17:17:28 +0000 ===
    2016-01-19T17:17:28.101095+00:00 app[web.1]: [3] - Goodbye!
    2016-01-19T17:17:28.974002+00:00 app[web.1]: [3] * Listening on tcp://0.0.0.0:18058
    2016-01-19T17:17:28.974157+00:00 app[web.1]: [3] Use Ctrl-C to stop
    2016-01-19T17:17:28.978252+00:00 app[web.1]: [3] - Worker 0 (pid: 6) booted, phase: 0
    2016-01-19T17:17:28.994863+00:00 heroku[web.1]: Process exited with status 0
    2016-01-19T17:17:28.979382+00:00 app[web.1]: [3] - Worker 1 (pid: 10) booted, phase: 0
    2016-01-19T17:17:29.346266+00:00 heroku[web.1]: State changed from starting to up

我应该怎么办?

4

1 回答 1

0

你需要 在你的路线中设置config.action_cable.url& config.action_cable.allowed_request_origins& mount ActionCable.server

于 2016-07-29T16:40:05.550 回答