Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Heroku:Rails 5 WebSocket连接失败_Heroku_Reactjs_Websocket_Ruby On Rails 5_Actioncable - Fatal编程技术网

Heroku:Rails 5 WebSocket连接失败

Heroku:Rails 5 WebSocket连接失败,heroku,reactjs,websocket,ruby-on-rails-5,actioncable,Heroku,Reactjs,Websocket,Ruby On Rails 5,Actioncable,我正在尝试在heroku上部署rails 5上的reactjs应用程序这是我的程序文件 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! racku

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

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
我该怎么办?

您需要设置
config.action\u cable.url
&
config.action\u cable.allowed\u request\u origins
&
mount ActionCable.server
在您的路径中

您应该在cable.yml中的密码字段中包含此f9e8821e7e25167ae7023516bd3fce13