I've been trying everything I can find online, and nothing is working. Hoping some fresh eyes will see the issue. This is my first time using ActionCable, and everything works great locally, but when pushing to heroku. my logs do not show any actioncable subscriptions like my dev server:
[ActionCable] [email#email.com] MsgsChannel is streaming from msg_channel_34
and when sending a message, I do see [ActionCable] Broadcasting to msg_channel_34: but they are not appending, which I'm guessing means that the received method is not being accessed/called?
I do notice on heroku's logs it says Listening on tcp://0.0.0.0:5000 where as dev it is listening at localhost:3000. Should I be pointnig towards my heroku app somehow?
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 can see that the port it's listening to is changing, making me believe 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
config/environments/development.rb
config.action_cable.allowed_request_origins = ['localhost:3000']
config.action_cable.url = "ws://localhost:3000/cable"
config/environments/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']
config/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"] %> is set, confirmed by running heroku config
routes.rb
mount ActionCable.server => '/cable'
Why is this working on dev, but not on heroku? I've been reading for hours, but can not figure it out. Thank you!!
UPDATE:
heroku 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
The issue was my host is the heroku app, but the requests were coming from the custom 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"
Is your app name literally app-name? I suspect not. 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']
Need to be updated to use the actual public-facing URL you intend to connect to.
Your procfile suggests that you run puma with cable/cable.ru on port 28080. Also - file cable/config.ru shouldn't contain this line:
ActionCable.server.config.allowed_request_origins = ["http://localhost:3000"]
You already configured this in config/environment/*.rb
I had the same issue, and found the answer I needed here: redis gem 4+ incompatibility "Specified 'redis' for Action Cable pubsub adapter, but the gem is not loaded". Once I downgraded my redis to 3.1.0, worked perfectly.
After running:
bundle exec rake assets:precompile RAILS_ENV="production"
I run rails s -e production but I am getting following error and server is not starting.
rails s -e production
=> Booting WEBrick
=> Rails 4.2.4 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server Exiting
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport4.2.4/lib/active_support/dependencies.rb:274:in `require':
C:/Users/app/models/~$Meeting.rb:1: Invalid char `\x03' in expression (SyntaxError)> from
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:274:in `block in require'from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
But running the application on development is working fine.
I keep getting this in the heroku log:
14-10-30T12:59:51+00:00 heroku[slug-compiler]: Slug compilation finished
2014-10-30T12:59:51.608050+00:00 heroku[web.1]: State changed from crashed to starting
2014-10-30T13:00:00.705131+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 35211 -c ./co
nfig/unicorn.rb`
2014-10-30T13:00:03.661476+00:00 app[web.1]: I, [2014-10-30T13:00:03.661285 #2] INFO -- : Refreshing Gem list
2014-10-30T13:00:15.728226+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2014-10-30T13:00:21.655877+00:00 heroku[web.1]: State changed from starting to crashed
checked pretty much everything all answers in google.
db:setup worked
db:migrate worked
config.assets.initialize_on_precompile = false is set
it's not only heroku, I also get the same error in local production environment:
Macs-MacBook-Pro:v1 mac$ RAILS_ENV=production rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Connecting to database specified by database.yml
Exiting
here is database.yml
production:
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode
database: s1_development
pool: 5
username: postgres
password: password
don't have any problems with local dev environment :(
WHat else can I do ? or how to find the problem ?
I'm having the hardest time trying to deploy a rails app to Heroku.
I push the app to it and receive no errors, but when I try to access it, I receive a 'no such app' message and I can't find out why.
I've followed this steps:
1) Cloned the git repo (https://github.com/mquan/lavish) in my local machine.
2) Changed the gemfile adding a newer version of the jquery-rails (as I was receiving an error) and added the 'thin' gem as stated at heroku documentation.
3) Installed it locally and it worked (in fact, it works if I run server rails, but not if I run server rails -e production).
4) Pushed it to heroku with no errors. (I tryed to precompile the assets too to see if I had any change).
5) When I visit the page (heroku open) I receive the 'No such app' message.
As I'm absolutely new to heroku and rails, I'm just clueless about what is happening.
Thanks a ton!
Edit
The log looks like this:
2012-11-14T06:36:28+00:00 heroku[web.1]: State changed from starting to down
2012-11-14T06:36:30+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -p 59071`
2012-11-14T06:36:35+00:00 app[web.1]: => Call with -d to detach
2012-11-14T06:36:35+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-11-14T06:36:35+00:00 app[web.1]: => Booting Thin
2012-11-14T06:36:35+00:00 app[web.1]: => Rails 3.2.0 application starting in production on http:// 0.0.0.0:59071
2012-11-14T06:36:35+00:00 app[web.1]: >> Thin web server (v1.5.0 codename Knife)
2012-11-14T06:36:35+00:00 app[web.1]: >> Maximum connections set to 1024
2012-11-14T06:36:35+00:00 app[web.1]: >> Listening on 0.0.0.0:59071, CTRL+C to stop
2012-11-14T06:36:39+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2012-11-14T06:36:40+00:00 app[web.1]: Exiting
2012-11-14T06:36:41+00:00 heroku[web.1]: Process exited with status 0
2012-11-14T20:00:11+00:00 heroku[slugc]: Slug compilation started
2012-11-14T20:01:58+00:00 heroku[slugc]: Slug compilation finished
2012-11-14T20:03:24+00:00 heroku[web.1]: Unidling
2012-11-14T20:03:24+00:00 heroku[web.1]: State changed from down to starting
2012-11-14T20:03:35+00:00 heroku[web.1]: State changed from starting to up
2012-11-14T20:03:37+00:00 heroku[router]: at=info method=GET path=/ host=blooming-castle-2034.herokuapp.com fwd= dyno=web.1 queue=0 wait=0ms connect=13ms service=909ms status=301 bytes=14
From looking at the code for Lavish, it looks like there is an initializer file that is loaded on Rails boot that redirects all non-www domain requests to www. Heroku wont work with the www prefix before your Heroku app url.
Here is a link to the file that should be removed
As a disclaimer, I'm not sure if this will have adverse effects on the Lavish application, since I've never dealt with it before.
I have followed book until chapter 5 finished and it's working OK in my linux workstation
when I push to Heroku, all data pushed correctly but when I try to open Heroku (http://vivid-sky-685.heroku.com)
I get a 404 message.
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
Below is my Gemfile for application
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3'
group :development do
gem 'rspec-rails', '2.5.0'
end
group :test do
gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc4'
end
gem 'rake','~> 0.8.7'
Any ideas what could be going wrong?
#odin here is my heroku logs , thanks
2011-09-11T10:41:57+00:00 heroku[router]: GET vivid-sky-685.heroku.com/y dyno=web.1 queue=0 wait=0ms service=5ms status=404 bytes=728
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 app[web.1]: Started GET "/y" for 93.186.31.80 at 2011-09-11 03:41:57 -0700
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 app[web.1]: ActionController::RoutingError (No route matches "/y"):
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 app[web.1]:
2011-09-11T10:41:57+00:00 heroku[nginx]: 93.186.31.80 - - [11/Sep/2011:03:41:57 -0700] "GET /y HTTP/1.1" 404 728 "-" "Mozilla/5.0 (BlackBerry; U; BlackBerry 9300; en) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.546 Mobile Safari/534.8+" vivid-sky-685.heroku.com
2011-09-11T11:45:28+00:00 heroku[web.1]: Idl
2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from up to down
2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from down to created
2011-09-11T11:45:29+00:00 heroku[web.1]: State changed from created to starting
2011-09-11T11:45:30+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-11T11:45:30+00:00 app[web.1]: >> Stopping ...
2011-09-11T11:45:30+00:00 heroku[web.1]: Process exited
2011-09-11T11:45:30+00:00 heroku[web.1]: Starting process with command `thin -p 16738 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-11T11:45:33+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-11T11:45:33+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-11T11:45:33+00:00 app[web.1]: >> Listening on 0.0.0.0:16738, CTRL+C to stop
2011-09-11T11:45:33+00:00 heroku[web.1]: State changed from starting to up
2011-09-11T12:53:00+00:00 heroku[web.1]: Idling
2011-09-11T12:53:01+00:00 heroku[web.1]: State changed from up to down
2011-09-11T12:53:02+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-11T12:53:02+00:00 app[web.1]: >> Stopping ...
2011-09-11T12:53:02+00:00 heroku[web.1]: Process exited
2011-09-11T13:18:21+00:00 heroku[rake.1]: State changed from created to starting
2011-09-11T13:18:23+00:00 app[rake.1]: Awaiting client
2011-09-11T13:18:23+00:00 app[rake.1]: Starting process with command `bundle exec rake db:migrate`
2011-09-11T13:18:26+00:00 heroku[rake.1]: Process exited
2011-09-11T13:18:26+00:00 heroku[rake.1]: State changed from up to complete
2011-09-11T13:20:02+00:00 heroku[web.1]: Unidling
2011-09-11T13:20:02+00:00 heroku[web.1]: State changed from down to created
2011-09-11T13:20:02+00:00 heroku[web.1]: State changed from created to starting
2011-09-11T13:20:04+00:00 heroku[web.1]: Starting process with command `thin -p 48393 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-11T13:20:06+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-11T13:20:06+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-11T13:20:06+00:00 app[web.1]: >> Listening on 0.0.0.0:48393, CTRL+C to stop
2011-09-11T13:20:07+00:00 heroku[web.1]: State changed from starting to up
2011-09-11T13:20:07+00:00 app[web.1]:
2011-09-11T13:20:07+00:00 app[web.1]:
2011-09-11T13:20:07+00:00 app[web.1]: Started GET "/" for 118.137.144.220 at 2011-09-11 06:20:07 -0700
2011-09-11T13:20:08+00:00 app[web.1]:
2011-09-11T13:20:08+00:00 app[web.1]: ActionController::RoutingError (uninitialized constant PagesController):
2011-09-11T13:20:08+00:00 app[web.1]:
2011-09-11T13:20:08+00:00 app[web.1]:
2011-09-11T13:20:08+00:00 app[web.1]:
2011-09-11T13:20:08+00:00 heroku[router]: GET vivid-sky-685.heroku.com/ dyno=web.1 queue=0 wait=0ms service=403ms status=404 bytes=728
2011-09-11T13:20:08+00:00 heroku[nginx]: 118.137.144.220 - - [11/Sep/2011:06:20:08 -0700] "GET / HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0" vivid-sky-685.heroku.com
I know it's an old problem but I ran into it too. I realized I didn't change the root route in config/routes.rb before pushing. Not changing it might result in a welcome page locally, but on heroku it will get the above error.
I got the same problem; however, after changing 1 line code of production.rb located in config/environments/production.rb from
config.assets.compile = false
to
config.assets.compile = true
commit the new change. Then my sample app works fine on heroku
I'm using postgresql, and I also had page not showing up on heroku.
This command fixed it:
heroku run rake db:setup
and then
heroku rake db:migrate
I had migrated before, but hadn't done the setup first.
I also had tried setting
config.assets.compile = true
in production.rb, but that made no difference.
Have you tried running in production mode locally? Try rails server -e production and see if you get the same error, which you can then debug. Also make sure you've done heroku rake db:migrate.
In my case it was a missing starting page that did not cause a problem in development mode but did cause the above issue on heroku. The accepted answer on this thread sheds more light.
Ran into this problem as well. Solved it by setting a root route. In my case, root 'pages#home' in config/routes.rb
If the root route is not set, you are redirected to localhost:3000. Hence,
The page you were looking for doesn't exist. You may have mistyped the
address or the page may have moved.
1. Always set a root in routes. That's rails 101
I wouldn't go for making asset pre-compilation false all the time. For production app I feel it enhances the overall speed if assets have been pre-compiled.
2. As a rule of thumb I always run rake assets:precompile before pushing to git. Please try it. and then commit to git repository and then heroku. Do heroku restart
3. Another cause could be heroku rake db:migrate, please check if you did it
4. Also this is my Gemfile setup for the development and production groups
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'heroku-deflater'
end
I had a very similiar issue with heroku, found the answer from this question:
RefineryCMS routes for Home page doesn't work
To save you reading, the solution was to update "Home" using Advanced Options, there is a question:
"Forward this page to another website or page"
Fill this in with a / and it should work. This sounds a little backwards, as its actually setting /my_page to redirect to "/". But the way to think of it is:
Refinery pages extension is looking for a page with the url '/' to be
the home page. So by telling the page titled "Home" that you want it
to have the url '/' you're setting it as the definitive homepage as
far as Refinery pages extension is concerned.
(quote from #Philip Arndt)
So I had to run in this order and it worked for me
$ heroku rake db:migrate
$ heroku run rake db:setup
Specify Ruby version in app
Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the ruby DSL in your Gemfile.
At the end of Gemfile add:
ruby "2.4.1"
I had the same problem, but the thing is that the app is missing the home like root. The default home page for Heroku is this HTMLthe default page. But if you try all your defined routes they will work like:
appname.herokuapp.com/route
I got the same error but realized that I hadn't change the HTML verb from GET to ROOT in config/routes.rb file.
It was get "/hello", to: "application#hello"
I updated it to root "application#hello"
I then pushed it to git and deployed it to production.
I was facing the same error because I pushed same non-master branch to heroku master using this command git push heroku master . Which obviously cause conflicts.
I also checked the routes using heroku run rake routes. But the output was not my actual routes. Not even single one.
The proper way to push your non-master branch to heroku master is
git push -f heroku your_branch_name:master