-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Hello,
Trying to do a basic implementation here, on version 0.5.0
import { NtpTimeSync } from 'ntp-time-sync';
const defaultOptions = {
// list of NTP time servers, optionally including a port (defaults to 123)
servers: [
'0.pool.ntp.org',
'1.pool.ntp.org',
'2.pool.ntp.org',
'3.pool.ntp.org',
],
// required amount of valid samples in order to calculate the time
sampleCount: 8,
// amount of time in milliseconds to wait for a single NTP response
replyTimeout: 3000,
// defaults as of RFC5905
ntpDefaults: {
port: 123,
version: 4,
tolerance: 15e-6,
minPoll: 4,
maxPoll: 17,
maxDispersion: 16,
minDispersion: 0.005,
maxDistance: 1,
maxStratum: 16,
precision: -18,
referenceDate: new Date('Jan 01 1900 GMT'),
},
};
const timeSync = NtpTimeSync.getInstance(defaultOptions);
export const getNtpTime = async () => {
try {
const time = await timeSync.getTime();
return time;
} catch (error) {
console.error('Error getting NTP time:', error);
return null;
}
And getNtpTime fails with this error:
Error: Connection error: Unable to get any NTP response after 3 retries
Am I doing something wrong?
Metadata
Metadata
Assignees
Labels
No labels