Installed NodeJS on Raspberry Pi, is there a way to check if the rPi is connected to the internet via NodeJs ?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- RMI Threads prevent JVM from exiting after main()
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
While robertklep's solution works, it is far from being the best choice for this. It takes about 3 minutes for
dns.resolve
to timeout and give an error if you don't have an internet connection, whiledns.lookup
responds almost instantly with the errorENOTFOUND
.So I made this function:
This is by far the fastest way of checking for internet connectivity and it avoids all errors that are not related to internet connectivity.