Closed BugerDread closed 5 years ago
Related to #21?
Related to #21?
not sure, I dont think is related to lost WiFi signal (as the esp is in the same room as the AP) and always shifts me to 2036-02-07 about 7:30 when occurs.
Hmmm, interesting. Thanks for spending the time documenting. I think I only parse an NTP packet if it is valid, but clearly something is wrong there. I will have a look at that code as soon as I have some time. Worst case I can just reject that particular time as invalid so it would retry 5 seconds later, but I'd rather spend a bit more time to figure out what's going on.
Im happy to spend time to improve something what is worth, also when it helps others to avoid problems... Thank you
I found ezTime very usefull and want to use it in my home automation project. If you need something that can help you to investigate this, Im ready to help / test / etc...
Hi Ropg, I decided to try to fix this myslef, right now I added following into ezTime.cpp line 484 (release 0.7.9) and switched debuglevel to "debug" to be able to see the data received:
//print out received for debug
int i;
debug(F("Received data:"));
for (i = 0; i < NTP_PACKET_SIZE; i++) {
if ((i % 4) == 0) {
debugln();
debug(String(i) + ": ");
}
debug(buffer[i], HEX);
debug(F(", "));
}
debugln();
Now will wait until the issue occurs again and will inform you about the progress.
Im also thinking about to add condition into updateNTP function to check the "correction" and update the time only when correction < something_like_1_minute (or configurable) - to avoid stupid updates which shifts the time years ago or ahead.
First of all I have to say that there was a strong wind yesterday and my internet connection was unstable - because the log I captured yesterday is showing the problem occurred right after there was a problem with connection (in contrast with other logs I captured before, like that in first comment, not showing any problem with connection at all).
# 2019-03-04 18-35-00
# 2019-03-04 18-36-00
# 2019-03-04 18-37-00
Running event (#1) set for Monday, 04-Mar-2019 17:37:08 UTC
Querying pool.ntp.org ... ERROR: Timeout
Set event (#1) to trigger on: Monday, 04-Mar-2019 17:37:23 UTC
Running event (#1) set for Monday, 04-Mar-2019 17:37:23 UTC
Querying pool.ntp.org ... ERROR: Timeout
Set event (#1) to trigger on: Monday, 04-Mar-2019 17:37:32 UTC
Running event (#1) set for Monday, 04-Mar-2019 17:37:32 UTC
Querying pool.ntp.org ... success (round trip 40 ms)
Received data:
0: E4, 0, 9, EC,
4: 0, 0, 0, 0,
8: 0, 0, 0, 0,
12: 52, 41, 54, 45,
16: 0, 0, 0, 0,
20: 0, 0, 0, 0,
24: 0, 0, 0, 0,
28: 0, 0, 0, 0,
32: 0, 0, 0, 0,
36: 0, 0, 0, 0,
40: 0, 0, 0, 0,
44: 0, 0, 0, 0,
Received time: Thursday, 07-Feb-36 06:28:16.032 UTC (internal clock was 1681499275 ms fast)
Set event (#1) to trigger on: Thursday, 07-Feb-2036 06:38:16 UTC
# 2036-02-07 07-28-16
# 2036-02-07 07-29-00
# 2036-02-07 07-30-00
# 2036-02-07 07-31-00
# 2036-02-07 07-32-00
# 2036-02-07 07-33-00
# 2036-02-07 07-34-00
# 2036-02-07 07-35-00
# 2036-02-07 07-36-00
# 2036-02-07 07-37-00
# 2036-02-07 07-38-00
Running event (#1) set for Thursday, 07-Feb-2036 06:38:16 UTC
Querying pool.ntp.org ... success (round trip 70 ms)
Received data:
0: 24, 2, 9, E9,
4: 0, 0, 0, 33,
8: 0, 0, 8, 9C,
12: C3, 71, 90, EE,
16: E0, 27, E0, FA,
20: D9, 38, E4, 3F,
24: 0, 0, 0, 0,
28: 0, 0, 0, 0,
32: E0, 27, E3, 34,
36: 24, FE, 3, 0,
40: E0, 27, E3, 34,
44: 25, 3, CD, 9A,
Received time: Monday, 04-Mar-19 17:47:32.193 UTC (internal clock was 1681499188 ms slow)
Set event (#1) to trigger on: Monday, 04-Mar-2019 17:57:32 UTC
# 2019-03-04 18-47-32
# 2019-03-04 18-48-00
So the bad packet was in this case
0: E4, 0, 9, EC,
4: 0, 0, 0, 0,
8: 0, 0, 0, 0,
12: 52, 41, 54, 45,
16: 0, 0, 0, 0,
20: 0, 0, 0, 0,
24: 0, 0, 0, 0,
28: 0, 0, 0, 0,
32: 0, 0, 0, 0,
36: 0, 0, 0, 0,
40: 0, 0, 0, 0,
44: 0, 0, 0, 0,
I read some docs about NTP namely: this by cisco and rfc4330
In that packet there is "stratum" byte (buffer[1]) = 0, there are no timestamps, and the "reference identifier" is "52, 41, 54, 45" means "RATE" in ascii.
They both say that reply with "stratum" = 0 (or anything else than 1..15) is not valid, more info about this is in the rfc4330 paragraph "8. The Kiss-o'-Death Packet"
So my plan is:
First attempt to fix, compiled, logging running....
^^^ seems to be running fine, so far not a single "2036-02-07 ...." occurrence
I observe this bug too. ROPG: do do you have a plan to accept BurgerDreads pull request or fix it by another way? I thing that now is good time to have this fix for next library release forced by bugs #38 & #41.
Yes, I plan to release a new version today.
Rop
Supposedly fixed (means I haven't tested because I do not see this condition) by merging pull request (thanks Bugerdread)
Hallo,
I made simple NTP clock using your ezTime library (https://github.com/BugerDread/esp8266-ezTIME-wifi-clock), but I noticed that it sometimes shows wrong time / date randomly. The wrong time / date is always 2036-02-07 about 7:30 (timezone Europe/Prague). So I made a simple sketch sending actual time and ezTime debug data to serial port which I captured to file.
Here is the testing sketch:
Here is the (truncated) log:
It occurs sometimes once / twice a day, randomly, it gets fixed after 10minutes as another sync is performed (as visible in the log above).
What can be source of the problem and how to avoid this?
Ggling around I found https://forum.arduino.cc/index.php?topic=92632.0 - maybe same or simmilar problem?
Ofcourse I can provide you with more info, just let me know...