R
Railway7mo ago
AD DAB

time on railway is off

i'm running a service that's very time senstive, it's been running smoothly for a long time but in the last 2-3 days i been having way too many issues with it. and now while testing, i discovered that Railway is off by around 3 seconds, been constantly getting it over 3 seconds. also, here's how i tested it:
async function compareTime() {
// Get local time
const localTime = new Date()

// Fetch accurate time from an API
try {
const response = await fetch("http://worldtimeapi.org/api/ip")
const body = await response.json()
const apiTime = body.unixtime
console.log("Accurate time from API: ", apiTime )

// Compare times and log the difference
// Note: The difference is in seconds
const timeDifference = apiTime - localTime.getTime() / 1000
console.log("Time difference (in seconds): ", timeDifference)
} catch (error) {
console.error("Error fetching time from API: ", error)
}
}
async function compareTime() {
// Get local time
const localTime = new Date()

// Fetch accurate time from an API
try {
const response = await fetch("http://worldtimeapi.org/api/ip")
const body = await response.json()
const apiTime = body.unixtime
console.log("Accurate time from API: ", apiTime )

// Compare times and log the difference
// Note: The difference is in seconds
const timeDifference = apiTime - localTime.getTime() / 1000
console.log("Time difference (in seconds): ", timeDifference)
} catch (error) {
console.error("Error fetching time from API: ", error)
}
}
is there a way around it?
No description
9 Replies
Percy
Percy7mo ago
Project ID: bdf3d4a1-76df-4946-a23e-eef74563bf0b
AD DAB
AD DAB7mo ago
bdf3d4a1-76df-4946-a23e-eef74563bf0b
Brody
Brody7mo ago
can you redo this kind of test, but use a proper time server to get the time, ntp-time-sync may help you
AD DAB
AD DAB7mo ago
@Brody
No description
AD DAB
AD DAB7mo ago
pretty sure an issue on the server, since i have 2 servers running and one of them got the time accurate and the other got it off milliseconds
Brody
Brody7mo ago
so now the time offset is negative? as opposed to being positive in your original screenshot?
AD DAB
AD DAB7mo ago
if you look into the code snippet, the clock is behind by 2 seconds but it's not showing as a negative also, i have 2 servers and i'm running the same code in them, one is pretty accurate(around 500 ms) and this one is not so much, doing around 2000 ms +
angelo
angelo7mo ago
Whats the usecase, is it key signing?
AD DAB
AD DAB7mo ago
yes i have a game that's very time sensitive, it's a web3 game so yeah it's signing involves a cryptographic key signing if that's what you mean
Want results from more Discord servers?
Add your server
More Posts