ping-tcp-js
v2.0.4
Published
<h1 align="center">Welcome to ๐</h1>
Downloads
511
Readme
install
npm install ping-tcp-js
ping
- param
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
await client.ping(
{ host, port },
{ timeout: 5000 } // optional
);
- host
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
client
.ping({ host, port })
.then(() => console.log("connect ping"))
.catch((e) => console.error("not disconnet", e));
- url
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "https://google.com";
client
.ping({ host })
.then(() => console.log("connect ping"))
.catch((e) => console.error("not disconnet", e));
pingBackOff
time : Reconnect time count : Number of times
- param
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
// or
client.pingBackOff({ host, port }, { time: 5000, count: 10, timeout: 5000 });
- host
const host = "google.com";
const port = 80;
client
.pingBackOff({ host, port }, { time: 5000, count: 10, timeout: 5000 })
.then(() => console.log("connect pingBackOff"))
.catch((e) => console.error("not disconnet", e));
- url
const host = "https://google.com";
client
.pingBackOff({ host: host }, { time: 5000, count: 10, timeout: 5000 })
.then(() => console.log("connect pingBackOff"))
.catch((e) => console.error("not disconnet", e));
Test
npm run test