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

How to check if an url is uncreachble ? #15

Closed
andibastian opened this issue Mar 9, 2017 · 3 comments
Closed

How to check if an url is uncreachble ? #15

andibastian opened this issue Mar 9, 2017 · 3 comments

Comments

@andibastian
Copy link

andibastian commented Mar 9, 2017

hello, i'm confuse, how to use this great script to check if an url is unreachable ?

I'm write like these :

isReachable('google.com').then(reachable => {
//createWindow();
if(reachable==true){
console.log("OK")
}
else {
console.log("Error")
}
});

but, the result is always not stable, sometime true, sometime false

@sindresorhus
Copy link
Owner

sindresorhus commented Mar 9, 2017

I guess you have some interference on your connection or something. You probably want the higher-level module is-online instead though.

@adiii717
Copy link

I also want to check if URL is not reachable and I also want to increase the timeout. I do want to create an issue because it's not an issue and there is no clear mention in the documentation. But just mention like its dependency module https://www.npmjs.com/package/is-port-reachable
Thanks

@silverwind
Copy link
Collaborator

check if URL is not reachable

Something like this (in an async function). The value on timeout depends on how fast the target server can handshake, but this should typically complete under a second:

const notReachable = !(await isReachable(url, {timeout: 1000}));

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