The action cable is signed locally, but not on the hero.

I try to find everything I can find on the Internet, and nothing works. Hoping some fresh eyes will see the problem. This is my first time using ActionCable, and everything works perfectly in place, but when clicking on the hero. my actioncable subscriptions, such as my dev server, are not displayed in my logs:

[ActionCable] [ email@email.com ] MsgsChannel is streaming from msg_channel_34 

and when sending a message, I see [ActionCable] Broadcasting to msg_channel_34: but they are not an addition, which I think means that the received method is not available or called?

I notice in heroku logs that he says Listening on tcp://0.0.0.0:5000 , where, like dev, he listens on localhost: 3000. Should I somehow point to my heroku application?

Here are the relevant configuration files:

PROCFILE:

 web: bundle exec puma -p 5000 ./config.ru actioncable: bundle exec puma -p 28080 cable/config.ru redis: redis-server 

*** Thanks to the comment below, I am also trying. Still not working, but I see that the port that he is listening to is changing, making me believe that it has something to do with the configuration?

 web: bundle exec puma -p $PORT ./config.ru actioncable: bundle exec puma -p $PORT cable/config.ru redis: redis-server 

/cable/config.ru

 require ::File.expand_path('../../config/environment', __FILE__) Rails.application.eager_load! ActionCable.server.config.allowed_request_origins = ["http://localhost:3000"] run ActionCable.server 

configurations / environment / development.rb

 config.action_cable.allowed_request_origins = ['localhost:3000'] config.action_cable.url = "ws://localhost:3000/cable" 

configurations / environment / production.rb

 config.web_socket_server_url = "wss://app-name.herokuapp.com/cable" config.action_cable.allowed_request_origins = ['https://app-name.herokuapp.com', 'http://app-name.herokuapp.com'] 

configurations / cable.yml

 local: &local adapter: async :url: redis://localhost:6379 :host: localhost :port: 6379 :timeout: 1 :inline: true development: *local test: *local production: :url: redis:<%= ENV["REDISTOGO_URL"] %> adapter: redis 

<%= ENV["REDISTOGO_URL"] %> set, confirmed by running heroku configuration

routes.rb

 mount ActionCable.server => '/cable' 

Why does this work on dev, but not on hero? I read for hours, but I can’t understand. Thanks!

UPDATE: Hero Logs:

 2017-01-25T20:32:57.329656+00:00 heroku[web.1]: Starting process with command `bundle exec puma -p 5000 ./config.ru` 2017-01-25T20:32:59.600554+00:00 app[web.1]: Puma starting in single mode... 2017-01-25T20:32:59.600574+00:00 app[web.1]: * Version 3.6.2 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity 2017-01-25T20:32:59.600575+00:00 app[web.1]: * Min threads: 0, max threads: 16 2017-01-25T20:32:59.600577+00:00 app[web.1]: * Environment: production 2017-01-25T20:33:02.375128+00:00 app[web.1]: profile controller 2017-01-25T20:33:02.588653+00:00 app[web.1]: Use Ctrl-C to stop 2017-01-25T20:33:02.588446+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5000 2017-01-25T20:33:17.681469+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-01-25T20:33:17.681469+00:00 heroku[web.1]: Stopping process with SIGKILL 2017-01-25T20:33:17.862118+00:00 heroku[web.1]: Process exited with status 137 2017-01-25T20:33:57.501746+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-01-25T20:33:57.501908+00:00 heroku[web.1]: Stopping process with SIGKILL 2017-01-25T20:33:57.630071+00:00 heroku[web.1]: Process exited with status 137 2017-01-25T20:33:57.642753+00:00 heroku[web.1]: State changed from starting to crashed 
+6
source share
3 answers

The problem was in my host - the heroku application, but the requests came from a user domain.

To solve:

heroku config:set RAILS_HOST "http://www.example.com"

And then in production.rb:

config.action_cable.url = "wss://#{ENV['RAILS_HOST']}/cable"

+6
source

In your profile, you assume that you are running puma with cable / cable .ru on port 28080. Also, the cable-file / config.ru should not contain this line:

 ActionCable.server.config.allowed_request_origins = ["http://localhost:3000"] 

You have already configured this in config / environment / *. rb

+2
source

Is your application name literally app-name ? I suspect not. The odds are pretty good that these values ​​...

 config.web_socket_server_url = "wss://app-name.herokuapp.com/cable" config.action_cable.allowed_request_origins = ['https://app-name.herokuapp.com', 'http://app-name.herokuapp.com'] 

You must update to use the actual public URL you are about to connect to.

+1
source

Source: https://habr.com/ru/post/1014425/


All Articles