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

[BS] [ERROR] Proxy address not reachable. Is your server running? #25

Closed
sogko opened this issue Aug 10, 2014 · 9 comments
Closed

[BS] [ERROR] Proxy address not reachable. Is your server running? #25

sogko opened this issue Aug 10, 2014 · 9 comments

Comments

@sogko
Copy link

sogko commented Aug 10, 2014

Hi,
I was working on trying to get gulp + browser-sync + nodemon to play nice with an expressJS app and I finally got it working, except for one issue that I'm not sure about.

The gist for the gulpfile.js and related files are at https://gist.github.com/sogko/b53d33d4f3b40d3b4b2e

When running gulp with the following config, I get the following error

[21:52:52] Using gulpfile ~/dev/testgulp/gulpfile.js
[21:52:52] Starting 'nodemon'...
[gulp] [nodemon] v1.2.1
[gulp] [nodemon] to restart at any time, enter `rs`
[gulp] [nodemon] watching: *.*
[gulp] [nodemon] starting `node app.js`
[21:52:52] Finished 'nodemon' after 18 ms
[21:52:52] Starting 'browser-sync'...
[21:52:52] Finished 'browser-sync' after 6.14 ms
[21:52:52] Starting 'default'...
[21:52:52] Finished 'default' after 17 μs
[BS] Proxying: http://localhost:5000
[BS] Now you can access your site through the following addresses:
[BS] Local: >>> http://localhost:7000
[BS] External: >>> http://192.168.1.1:7000

[BS] [ERROR] Proxy address not reachable. Is your server running?

But browser-sync was able to launch google-chrome with the application running at http://localhost:7000/

Both injection and reload both seems to be working. (editing css would inject, editing html would reload)

How am I supposed to deal with the error message?

Thanks!

@shakyShane
Copy link
Contributor

It's actually a new 'feature' that I added to stop me trying to proxy to VMs when they were not running yet.

All that happens, is that BrowserSync makes a request for the page you're proxying at start-up time and that error is just saying at that time, it didn't return a 200 response.

You can just ignore it for now, but perhaps it should be moved to 'debug' log level instead....

@sogko
Copy link
Author

sogko commented Aug 14, 2014

That makes sense, maybe debug level might trivialise its significance a little bit, because it is actually a valid concern (whether the server that I'm trying to proxy to is actually running)

Perhaps, may I suggest moving it to warn log level instead? Its not fatal enough to warrant an error but still more important than debug?

Anyway, great work on the library, unbelievably a must-have tool!

Thanks!

@shakyShane
Copy link
Contributor

thanks!!

& yes, agreed it should be under warn level.

@shakyShane
Copy link
Contributor

(logging is in process of huge overhaul anyway, so it'd be a good time to add it)

@krry
Copy link

krry commented Aug 16, 2014

Oh, good, someone else is seeing the same errant error. I too am using gulp, nodemon, and browserSync on an express app with great relish. Everything is working very well, thanks for putting BS out there.

@PiiXiieeS
Copy link

I found this weird ERROR message could be removed by commenting the line logError below in the function checkProxyTarget. To be honest I don't fully understand what is the control expected in this function as the Proxy connection will be initiated anyway by function createProxy(options, scripts):

/**
 * @param {Object} proxy
 * @param {Object} options
 */
function checkProxyTarget(proxy, options) {

    var chunks  = [];
    var errored = false;

    function logError() {
        if (!errored) {
            log("info", messages.proxyError(), options);
            errored = true;
        }
    }

    require("http").get(proxy.target, function (res) {
        res.on("data", function (data) {
            chunks.push(data);
        });
    }).on("error", function (err) {
        if (err.code === "ENOTFOUND") {
            logError();
        }
    }).on("close", function () {
        if (!chunks.length) {
            console.log(data);
            //logError();    <----- ERROR is logged under the assumption the connection is closed
        }
    });
}

@shakyShane
Copy link
Contributor

@PiiXiieeS - as mentioned above:

"It's actually a new 'feature' that I added to stop me trying to proxy to VMs when they were not running yet."

granted it's sometimes incorrect (as it can lose in certain race-conditions) & that's why we'll be demoting the error to a warning in a future release.

"To be honest I don't fully understand what is the control expected in this function as the Proxy connection will be initiated anyway by function createProxy(options, scripts):" - it's not there to control anything in BrowserSync, it's just a flag to say "hey, that address can't be reached right now"

@PiiXiieeS
Copy link

Thanks @shakyShane!
"granted it's sometimes incorrect (as it can lose in certain race-conditions)"
So maybe the problem is linked to my gulpfile because I always get that message no matter how many times I may run the gulp command.

I put my gulpfile in a Gist. It is heavily based on the gulp recipe browser-sync-nodemon-expressjs created by @sogko but somehow I could not make it work with watch so I use the ext option as described in the gulp-nodemon documentation.

My gulpfile.js version: expressjs-nodemon-browsersync... it works like a charm except for the already mentioned error message (thanks @shakyShane for this great piece of code)

@shakyShane
Copy link
Contributor

this msg now demoted to warn level in >= 1.5.1

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