How to use is-reachable - 5 common examples

To help you get started, we’ve selected a few is-reachable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cgrossde / Pullover / src / app / services / ConnectionManager.js View on Github external
isOnline(function(err, internetOnline) {
    if (internetOnline) {
      // Is pushover reachable
      isReachable('api.pushover.net:443', function(error, reachable) {
        if (reachable) {
          debug.log('We are online again')
          clearInterval(checkInternetInterval)
          online()
        }
        checkingInternet = false
      })
    }
    else {
      checkingInternet = false
    }
  })
}
github huridocs / uwazi / app / api / topicclassification / api.ts View on Github external
export async function getModels() {
  const tcUrl = new URL('models', tcServer);
  const msTimeout = 1000;
  if (!(await isReachable(tcUrl.href, { timeout: msTimeout }))) {
    // TODO: move this backend check to server start-up time, maybe
    return {
      models: {},
      error: `Topic Classification server is unreachable (${msTimeout})`,
    };
  }
  return fetch(tcUrl.href, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  })
    .then(async res => res.json())
    .catch(err => {
      return {
        models: {},
github huridocs / uwazi / app / api / topicclassification / api.ts View on Github external
export async function checkModelReady(arg: { model: string }) {
  const tcUrl = new URL('models', tcServer);
  tcUrl.searchParams.set('model', arg.model);
  const msTimeout = 1000;
  if (!(await isReachable(tcUrl.href, { timeout: msTimeout }))) {
    // TODO: move this backend check to server start-up time, maybe
    return { models: {}, error: `Topic Classification server is unreachable (${msTimeout})` };
  }
  return fetch(tcUrl.href, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  })
    .then(async res => res.json())
    .catch(err => {
      return {
        models: '',
        error: `Error from topic-classification server: ${err.toString()}`,
      };
    });
github ArkEcosystem / core / packages / core-json-rpc / src / server / services / network.ts View on Github external
private async getPeer(): Promise<{ ip: string; port: number }> {
        const peer: { ip: string; port: number } = sample(this.getPeers());
        const reachable: boolean = await isReachable(`${peer.ip}:${peer.port}`);

        if (!reachable) {
            this.logger.warn(`${peer} is unresponsive. Choosing new peer.`);

            return this.getPeer();
        }

        return peer;
    }
github parro-it / tunnels / src / modules / is-reachable-promise.js View on Github external
return new Promise((resolve, reject) => {
		isReachable(dests, (err, reachable) => {
			if (err) {
				reject(err);
			} else {
				resolve(reachable);
			}
		});
	});
}

is-reachable

Check if servers are reachable

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular is-reachable functions