From e48758698d17eaaf3c2d639ca6b4972d0a22fa9e Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sat, 7 Sep 2024 09:19:43 -0400 Subject: [PATCH 1/6] Fix: "Failed to retrieve real time from API, falling back to local time" Replaced http with https inside of retrieveTimeFromApi function. --- server/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.lua b/server/server.lua index f52c0d1..b085a10 100644 --- a/server/server.lua +++ b/server/server.lua @@ -124,7 +124,7 @@ end --- @return number - Unix time local function retrieveTimeFromApi(callback) Citizen.CreateThread(function() - PerformHttpRequest("http://worldtimeapi.org/api/ip", function(statusCode, response) + PerformHttpRequest("https://worldtimeapi.org/api/ip", function(statusCode, response) if statusCode == 200 then local data = json.decode(response) if data == nil or data.unixtime == nil then From 8eb3e7e998f2e77ed667ccd5ac31ebdc234d08ef Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:58:58 -0400 Subject: [PATCH 2/6] Fix 2: "Failed to retrieve real time from API, falling back to local time" Added a longer wait and higher fail count. --- server/server.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.lua b/server/server.lua index b085a10..58326a5 100644 --- a/server/server.lua +++ b/server/server.lua @@ -293,12 +293,12 @@ CreateThread(function() end) end while realTimeFromApi == nil do - if failedCount > 10 then + if failedCount > 15 then print("Failed to retrieve real time from API, falling back to local time") break end failedCount = failedCount + 1 - Wait(100) + Wait(1000) end if realTimeFromApi ~= nil then newBaseTime = realTimeFromApi From 52a35d5d6f6fc9d2779015f43a7f81dc25e8bd9f Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sun, 8 Sep 2024 19:02:41 -0400 Subject: [PATCH 3/6] Fix 3: "Failed to retrieve real time from API, falling back to local time" Removed extra wait time and added more to failedCount instead. --- server/server.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.lua b/server/server.lua index 58326a5..dc25171 100644 --- a/server/server.lua +++ b/server/server.lua @@ -293,12 +293,12 @@ CreateThread(function() end) end while realTimeFromApi == nil do - if failedCount > 15 then + if failedCount > 20 then print("Failed to retrieve real time from API, falling back to local time") break end failedCount = failedCount + 1 - Wait(1000) + Wait(100) end if realTimeFromApi ~= nil then newBaseTime = realTimeFromApi From 5cebc66c3701848c29ee6f639ddabfa8b25e6a0c Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sun, 8 Sep 2024 19:12:58 -0400 Subject: [PATCH 4/6] Fix 4: "Failed to retrieve real time from API, falling back to local time" Raised failedCount. --- server/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.lua b/server/server.lua index dc25171..462f066 100644 --- a/server/server.lua +++ b/server/server.lua @@ -293,7 +293,7 @@ CreateThread(function() end) end while realTimeFromApi == nil do - if failedCount > 20 then + if failedCount > 25 then print("Failed to retrieve real time from API, falling back to local time") break end From a3b52a53238cf6f49a996530ce31acca63f57863 Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sun, 8 Sep 2024 20:19:34 -0400 Subject: [PATCH 5/6] Fix 5: "Failed to retrieve real time from API, falling back to local time" Added more to failedCount and Wait. --- server/server.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.lua b/server/server.lua index 462f066..6fef25c 100644 --- a/server/server.lua +++ b/server/server.lua @@ -293,12 +293,12 @@ CreateThread(function() end) end while realTimeFromApi == nil do - if failedCount > 25 then + if failedCount > 60 then -- TESTING -- DEFAULT 10 print("Failed to retrieve real time from API, falling back to local time") break end failedCount = failedCount + 1 - Wait(100) + Wait(1000) --TESTING -- DEFAULT 100 end if realTimeFromApi ~= nil then newBaseTime = realTimeFromApi From 1b7f47500b4d3d02419ca8eb65b2dedb7b13d5e4 Mon Sep 17 00:00:00 2001 From: MerlinisaG <93505100+MerlinisaG@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:06:22 -0400 Subject: [PATCH 6/6] Confirming Fix for: "Failed to retrieve real time from API, falling back to local time" Cleaned up notes from testing. --- server/server.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.lua b/server/server.lua index 6fef25c..e3196e1 100644 --- a/server/server.lua +++ b/server/server.lua @@ -293,12 +293,12 @@ CreateThread(function() end) end while realTimeFromApi == nil do - if failedCount > 60 then -- TESTING -- DEFAULT 10 + if failedCount > 60 then print("Failed to retrieve real time from API, falling back to local time") break end failedCount = failedCount + 1 - Wait(1000) --TESTING -- DEFAULT 100 + Wait(1000) end if realTimeFromApi ~= nil then newBaseTime = realTimeFromApi