langpavel / node-ping-wrapper

Ping wrapper for node - one process listening on stdout is spawned; inherits from EventEmitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event "ping" never seems to fire

XanderZero opened this issue · comments

Hello there,
I have been trying to implement your ping-wrapper in a NodeJS of mine where to logic around the Pings was kind of complex, so I ended up doing a long debugging process before even taking a step back and doing some basic testing if the ping-wrapper module is even doing what it is supposed to at all.
And my impression is: No, it doesn't. Specifically in my tests the event "ping" never seems to fire, and even "fail" only in very specific scenarios.

//test if ping works properly at all
const Ping = require('ping-wrapper');
Ping.configure();

var pingTest = new Ping('google.com');
pingTest.on('fail', function(data) { console.log('PING TEST: fail'); });
pingTest.on('ping', function(data) { console.log('PING TEST: success'); });

In my tests it never fires positive for addresses that are actually reachable, and even the fail only fires in a very specific scenario where I have a domain set up that points at an IP address that is unreachable (and thus giving a "Destination host unreachable" error); but for a general ping timeout for IP addresses that do not exist it also doesn't fire.

I tried it with pingTest.start(); at the end, too.