breakfast icon indicating copy to clipboard operation
breakfast copied to clipboard

ubuntu auto reload not working

Open stevenwoudstra opened this issue 8 years ago • 11 comments

Hi guys, I'm having some problems with the auto reload function. When I save a file I can see in my console that it is compiling end sending the reload massage to my browser(chrome) only nothing happens.

I'm running rails on a Ubuntu 16.04.2 machine.

Part of my packege.json

{
  "repository": {},
  "dependencies": {
    "actioncable": "^5.0.0",
    "bourbon": "^4.3.3",
    "breakfast-rails": "0.5.0",
    "copycat-brunch": "^1.1.0",
    "highcharts": "^5.0.9",
    "jquery": "^3.1.0",
    "jquery-ujs": "^1.2.2",
    "postcss-lh": "^1.1.4",
    "turbolinks": "^5.0.0"
  },
  "devDependencies": {
    "autoprefixer": "^6.5.4",
    "babel-brunch": "~6.0.0",
    "brunch": "^2.10.8",
    "clean-css-brunch": "~1.8.0",
    "coffee-script-brunch": "^2.10.1",
    "postcss-brunch": "^0.5.0",
    "postcss-responsive-font": "^1.0.0",
    "postcss-scss": "^0.4.1",
    "sass-brunch": "^2.10.4",
    "uglify-js-brunch": "~2.1.0"
  }
}

screenshot from 2017-03-22 08-58-29 screenshot from 2017-03-22 08-59-09

stevenwoudstra avatar Mar 22 '17 08:03 stevenwoudstra

Hey thanks for creating an issue. Mind answering some of the following questions?

  1. What version of Rails
  2. What command are you using to start Rails? (rails s puma heroku local, etc).
  3. What Port are you running on? (I ask because by default ActionCable only broadcasts on Port 3000)
  4. If you open up the console in chrome are there any javascript errors?

PatKoperwas avatar Mar 22 '17 14:03 PatKoperwas

Thanks for helping me ^^

"I'm running on Rail 5.0.1, i'm starting the server with rails s but i use invoker(to run as "domain.dev") to do so. It's running on port 3000. I have no errors in chrome, only when i close the rails server then I get: WebSocket connection to 'ws://fr.domain.dev/cable' failed: Connection closed before receiving a handshake response

stevenwoudstra avatar Mar 22 '17 14:03 stevenwoudstra

Great, can you try this?

Just run bundle exec rails s -p 3000. Then navigate to http://localhost:3000 in the browser and see if it works.

If it does, I'm assuming that ActionCable (what this gem uses to push updates to the browser) isn't reaching the domain your using (domain.dev). Thankfully, it's a simple fix.

Buried deep in the ActionCable Guide: http://edgeguides.rubyonrails.org/action_cable_overview.html#allowed-request-origins

In config/environments/development.rb add this line

config.action_cable.allowed_request_origins = ['http://localhost:3000', 'http://domain.dev']

Just replace that last url with whatever url you run your app on.

Hopefully that fixes it 🤞

PatKoperwas avatar Mar 22 '17 15:03 PatKoperwas

I already did try run it over localhost:3000 and with bundle exec, no change I did indeed config action cable. my configs for action cable:

config.action_cable.disable_request_forgery_protection = true

  config.action_cable.allowed_request_origins = ['localhost:3000', 'domain1.dev', 'nl.domain2.dev', 'domain2.dev', 'en.domain2.dev']
  config.action_cable.url = ["ws://nl.domain2.dev/cable", "ws://domain1.dev/cable"]

So i have no idea wy its not working, the configs are working on a mac of a colleague of mine but is does not seem to work on ubuntu.

Also it looks like action cable does have a connection with my browser because when i close my server the undefined does change to Disconnected from server... screenshot from 2017-03-22 08-59-09 screenshot from 2017-03-22 16-58-07

stevenwoudstra avatar Mar 22 '17 15:03 stevenwoudstra

Hmm I'll fire up an Ubuntu 16.04 image later today and give it a spin.

PatKoperwas avatar Mar 22 '17 16:03 PatKoperwas

okee thanks a lot ^^

stevenwoudstra avatar Mar 23 '17 10:03 stevenwoudstra

So I've booted up a 16.04 image and it works. Running with Invoker as well

breakfast-ubuntu-16 04

@stevenwoudstra Can you try and open up the page in an incognito window?

PatKoperwas avatar Mar 27 '17 18:03 PatKoperwas

@stevenwoudstra in some versions of Ubuntu and other Linux distros the Inotify Watches Limit is too low. I think this will solve your issue.

https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit

haffla avatar May 11 '17 10:05 haffla

@haffla I just tried it but it didn't work...

stevenwoudstra avatar May 12 '17 08:05 stevenwoudstra

Sorry I think I didn't properly read your problem. Forget my comment. Your machine picks up the changes but the signal doesn't get pushed to the browser. In fact it's the same problem I'm having now (Rails 5, Ubuntu 16). I'm gonna setup a new rails project and see if it's working there.

haffla avatar May 12 '17 08:05 haffla

@stevenwoudstra do you happen to use Pace? In my case it was this library that caused the problem. It is basically incompatible with ActionCable WebSockets when using the default configuration. To make it work you need to put the following JS before the Pace JS

window.paceOptions = {
  ajax: {
    trackWebSockets: false
  }
}
  

Well if not check your other libraries if they mess around with Websockets.

haffla avatar May 12 '17 12:05 haffla