Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling for NTP server returning 0 #193

Closed
frankB415 opened this issue May 25, 2023 · 4 comments · May be fixed by #211
Closed

Add handling for NTP server returning 0 #193

frankB415 opened this issue May 25, 2023 · 4 comments · May be fixed by #211
Assignees
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@frankB415
Copy link

frankB415 commented May 25, 2023

I had some issues with wrong date as i used that lib on an ESP32. After debugging i found, that the NTP server sends from time to time "0" as response.

So I added 3 lines to handle that issue.

NTPClient.cpp:113:

  unsigned long secsSince1900 = highWord << 16 | lowWord;

  if (secsSince1900 == 0 ) { // failure value!!
    return false; 
  }

  this->_currentEpoc = secsSince1900 - SEVENZYYEARS;
@per1234 per1234 added type: imperfection Perceived defect in any part of project type: enhancement Proposed improvement topic: code Related to content of the project itself and removed type: imperfection Perceived defect in any part of project labels May 26, 2023
@per1234 per1234 changed the title failure reaction to invalid ntp-timestamp Add handling for NTP server returning 0 May 26, 2023
@dallday
Copy link

dallday commented Jun 11, 2023

Just noticed the same problem where the date shows as 07/02/2036 07:28:16, which seems to be the 0 value + 70 years :)
Is the problem with the UDP packet being returned and does it need a check to see if the correct packet has been received?

@gbanka
Copy link

gbanka commented Jul 18, 2023

I got the same error while offline for ~14 hours. I was using getEpochTime()

@Leonti
Copy link

Leonti commented Dec 8, 2023

Also had the issue with my watering system which has the following logic:

  1. Compare the scheduled time with the current time
  2. If it's time to water do the watering and update next watering time.
    Suddenly yesterday all of my plants started watering and the next scheduled time was in 106829 which is in 12.20 years, which is also year 2036.

Der-Schubi added a commit to Der-Schubi/NTPClient that referenced this issue Jun 23, 2024
Fixes arduino-libraries#193, fixes 84, fixes
Credits to @frankB415 for the Code in Issue arduino-libraries#193!
@per1234
Copy link
Contributor

per1234 commented Jun 23, 2024

Hi @frankB415. Thanks for taking the time to submit an issue.

I see we have another report about this at #84.

It is best to have only a single issue per subject so we can consolidate all relevant discussion to one place, so I'll go ahead and close this in favor of the other.

If you end up with additional information to share, feel free to comment in the other thread.

@per1234 per1234 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2024
@per1234 per1234 self-assigned this Jun 23, 2024
@per1234 per1234 added conclusion: duplicate Has already been submitted type: imperfection Perceived defect in any part of project and removed type: enhancement Proposed improvement labels Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants