Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yeoman Angular.js grunt serve-d app has very long latency from livereload.js?snipver=1

I followed Yeoman's guide to set up an Angular.js app. I didn't change anything except for the hostname from "localhost" to "0.0.0.0".

When I did grunt serve, there were no errors. Eventually I do get to see the "'Allo, 'Allo" front page, but only after over 30 seconds of latency from livereload.js?snipver=1, which failed to GET. As you can see on the right, the server doesn't output anything unusual.

livereload.js failed and causes a long latency

My entire project is on github.

I grep-ped for livereload and found a few suspects:

  • /node_modules/grunt-contrib-connect/node_modules/connect-livereload/index.js has these two functions below containing the livereload url. The first one links to "http://my.ip.addr.ess:9000/livereload.js", which has a "Cannot GET".

    function getSnippet() {
        /*jshint quotmark:false */
        var snippet = [ 
            "<!-- livereload script -->",
            "<script type=\"text/javascript\">document.write('<script src=\"http://'",
            " + (location.host || 'localhost').split(':')[0]",
            " + ':" + port + "/livereload.js?snipver=1\" type=\"text/javascript\"><\\/  script>')",
            "</script>",
            ""  
        ].join('\n');
        return snippet;
      };    
    
      function snippetExists(body) {
        if (!body) return true;
        return (~body.lastIndexOf("/livereload.js?snipver=1"));
      }
    
  • My Gruntfile.js which set livereload to be true, which I would like to keep.

Does anyone have a clue?


Update:

I tried on a brand new machine again, from scratch. I still get the same problem! This time the Status of livereload says "net::ERR_CONNECTION_TIMED_OUT".

enter image description here

More information: I'm running on AWS EC2 with only ports 8000 and 9000 open.


like image 830
randwa1k Avatar asked Feb 20 '14 03:02

randwa1k


1 Answers

After thinking about it, I determined that it couldn't have been Yeoman or any of my Ubuntu server's fault, because nothing changed after I wiped the machine clean and started over. It wasn't a blocked IP on the browser either, because both Chrome and Firefox had the same problem. It wasn't a blocked IP on my client machine because the problem persisted on another machine.

The light bulb went off when I actually looked into the exact URL livereload was requesting. It was requesting on port 35729, a port I haven't opened up on my AWS EC2 account!

enter image description here

After I opened up that port, it worked flawlessly!

like image 70
randwa1k Avatar answered Sep 19 '22 00:09

randwa1k