Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

ubuntu auto reload not working #18

Open
stevenwoudstra opened this issue Mar 22, 2017 · 11 comments
Open

ubuntu auto reload not working #18

stevenwoudstra opened this issue Mar 22, 2017 · 11 comments
Assignees
Labels

Comments

@stevenwoudstra
Copy link

stevenwoudstra commented Mar 22, 2017

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

@PatKoperwas
Copy link
Contributor

PatKoperwas commented Mar 22, 2017

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?

@stevenwoudstra
Copy link
Author

stevenwoudstra commented Mar 22, 2017

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

@PatKoperwas
Copy link
Contributor

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 🤞

@stevenwoudstra
Copy link
Author

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

@PatKoperwas
Copy link
Contributor

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

@stevenwoudstra
Copy link
Author

okee thanks a lot ^^

@PatKoperwas PatKoperwas self-assigned this Mar 24, 2017
@PatKoperwas
Copy link
Contributor

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?

@haffla
Copy link
Contributor

haffla commented May 11, 2017

@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

@stevenwoudstra
Copy link
Author

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

@haffla
Copy link
Contributor

haffla commented May 12, 2017

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
Copy link
Contributor

haffla commented May 12, 2017

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants