apaszke / tcp-ping Goto Github PK
View Code? Open in Web Editor NEWTCP ping utility for node.js
License: MIT License
TCP ping utility for node.js
License: MIT License
Hello,
I have been trying to return the data. It works totally fine when I do console.log....but then I need to use the data for something else.
Please find the code.
Thanks.
pingTest(){ let msg= 'false'; tcpp.probe('www.google.com', 80, function(err, available) { return console.log(available); //msg=available; }); return msg; }
I see msg contains only 'false'.
Ping err
argument always undefined regardless address valid or not.
Example:
const tcpp = require('tcp-ping');
// Ping VALID address
tcpp.ping({ address: 'google.com', timeout: 1000, attempts: 1 }, (err, data) => {
console.log(err); // log `undefined`
});
// Ping INVALID address
tcpp.ping({ address: 'node', timeout: 1000, attempts: 1 }, (err, data) => {
console.log(err); // log `undefined`
});
Specific option to only use IPV6 servers
I want to log my WAN availability, so i ping Google and my homepage to test if i can connect to them. Surprisingly probe is always returning true even tough i can not connect to anything at all.
I am not sure if i can just use avg and test for NaN to tell if i have no connection as that is the only clue i get when using ping of whether or not the connection failed. I assume so but i wanted to be sure so i ask here, maybe it would be a good idea to hint at this in the ReadMe.
Shouldn't this return false pretty much immediately? The timeout is 1ms. Instead it's waiting 21 seconds before returning false.
const tcp = require("tcp-ping");
let opts = {
address: "good address",
port: bad port,
timeout: 1
}
tcp.ping({ address: opts.address, port: opts.port, attempts: 1, timeout: opts.timeout }, function(err, data) {
let available = data.min !== undefined;
console.log(available);
});
I wrapped the ping function inside a promise as below.
const tcpping = opt => new Promise((resolve, reject) => tcpp.ping(opt, (err, data) => err ? reject(err) : resolve(data)));
Perhaps native support for promises could be added.
no matter what i try to do i am getting undefined response time.
tcp.ping({address:'google.com',attempts:5, timeout:150}, function(err, data){
console.log(data);
});
results: [{seq:0, time: undefined, err: {Object},
Hi! I was wondering if there are any docker images available with the tcp-ping package installed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.