TImeout exception in sntp
vrst37 opened this issue · comments
I am trying to use the SNTP module and it is giving me issues.
Here is the code (basically a copy paste of the code from the module's page):
var Sntp = require('sntp');
// All options are optional
var options = {
host: 'nist1-sj.ustiming.org', // Defaults to pool.ntp.org
port: 123, // Defaults to 123 (NTP)
resolveReference: true, // Default to false (not resolving)
timeout: 1000 // Defaults to zero (no timeout)
};
// Request server time
Sntp.time(options, function (err, time) {
if (err) {
console.log('Failed: ' + err.message);
process.exit(1);
}
console.log('Local clock is off by: ' + time.t + ' milliseconds');
process.exit(0);
});
And here is the traceback exception I am getting:
(node:29454) UnhandledPromiseRejectionWarning: Error: Timeout
at Timeout.settings.timeout.setTimeout (/home/edyza/temp/node_modules/sntp/lib/index.js:30:72)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
(node:29454) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:29454) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I am using Ubuntu 16.04LTS and Node version is 8.10.0.
Am I doing something wrong? Or is there a bug in the module?
First, the examples were not up to date. They are now. Second, I have no idea why you are getting a timeout. Try a different time server.
I am still timing out with the host 'nist1-sj.ustiming.org'. It works perfectly with pool.ntp.org.
Perhaps it will be better to use pool.ntp.org in the example code so it works for copy paste noobs like me out of the box :)
Thanks for helping out
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.