Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livereload doesn't work (does not bind localhost:35729/livereload) #350

Open
shadowmint opened this issue Jul 4, 2014 · 5 comments
Open

Comments

@shadowmint
Copy link

Live reload appears to be broken to me.

Other people seem to report it 'working' for them, but I've not actually managed to have anyone in this working state demonstrate it actually working to me, so I suspect it is in fact actually silently broken (see the chrome comment below; however, if I'm wrong and this is working somehow, my apologies).

Anyway, we start with a basic grunt watch task with livereload enabled:

watch: {
    sass: {
        files: ['<%= paths.src %>/*.scss'],
        tasks: ['sass:compile'],
        options: {
            livereload: true
        }
    }
}

After starting grunt watch, localhost:35729/livereload.js contains:

this._uri = "ws" + (this.options.https ? "s" : "") + "://" + this.options.host + ":" + this.options.port + "/livereload"; 

Note the trailing /livereload on this URI.

However, although /livereload should be an alias to /, inspecting grunt-contrib-watch/node_modules/tiny-lr-fork/lib/server.js, we see that only these routes are bound:

this.on('GET /', this.index.bind(this));
this.on('GET /changed', this.changed.bind(this));
this.on('POST /changed', this.changed.bind(this));
this.on('GET /livereload.js', this.livereload.bind(this));
this.on('GET /kill', this.close.bind(this));

Which is played out in reality by trying to hit :35729/livereload on the server:

{
    "error": "not_found",
    "reason": "no such route"
}

Practically what does this mean?

It means that if you try to use livereload, you'll get this:

Firefox can't establish a connection to the server at ws://locahost:35729/livereload.
http://0.0.0.0:35729/livereload.js?host=locahost&snipver=1
Line 191

Chrome is more forgiving in that it doesn't generate an error, it just sits polling :35729/livereload and doing nothing forever.

It may be worth noting that the livereload configuration is passed as options if you pass a hash in to the livereload request, eg. options: { livereload: { ... } }; but I can't see any way this can be used meaningfully to add the missing route.

@hugomagallanes
Copy link

I'd also like to know the answer to this question, since I'm having the same issue.

@x-hovo-x
Copy link

Same for me, anyone solved this?, please let us know

@hugomagallanes
Copy link

I eventually did manage to make it work. Honestly, I don’t remember the exact steps I took nonetheless here are my suggestions:

  • Make sure you have the live reload installed in your browser.
  • Temporally disable other extensions that might interfere with live reload.
  • Check if that specific port is enabled in your Firewall.

If it still doesn’t work I can try to further look into it.

@x-hovo-x
Copy link

@hugomagallanes, thanks for reply,

sorry to not mention it before, the problem, that other angular projects open with FF without any problem.
I disabled all extensions and even re-installed FF, doesn't help.

from console:
----------- start --------
Firefox can't establish a connection to the server at ws://localhost:35729/livereload.

this.socket = new this.WebSocket(this._uri);

liverel...ipver=1 (line 191)

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ...

---------- end----------

for all other browsers (safari, maxthon, chrome, opera ) it works perfectly

OS: macos
FF version: 35
angular version: ^1.3

please let me know if you need more information.

@NOUBISSI
Copy link

for me this was due to error in my angularjs code

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

No branches or pull requests

4 participants