apaszke / tcp-ping

TCP ping utility for node.js
MIT License
123 stars 27 forks source link

No reliable way of telling if the connection was successful or not. #7

Closed sayore closed 6 years ago

sayore commented 6 years ago

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.

apaszke commented 6 years ago

You can just use probe, and otherwise there's a results array in the the output that has more detailed per-attempt info. If you see that results[i].time is undefined, or that it has an err field, then it failed. If all of them satisfy those conditions, then no connection was successful. Hope this helps.