NTP time-out too short?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

NTP time-out too short?

#1 Post by Domosapiens » 16 Dec 2017, 22:14

Hello,
with the upgrade of 4 units to ESPEasy_v2.0.0-dev12 I discovered a NTP problem.
At boot, the time/date is not set to the NTP time but something with 1970 .... (that sounds Unix)
After a number of cold and warm boots and NTP On/Off and changing NTP servers .... I was able to get the 4 units back on the right time.
So happy with that, that I'm afraid to reboot now.

My NTP setting:
0.europe.pool.ntp.org setting Capture.JPG
0.europe.pool.ntp.org setting Capture.JPG (18.49 KiB) Viewed 5776 times

I also used-
- an empty field (empty defaults to pool.ntp.org)
- nl.pool.ntp.org
- europe.pool.ntp.org


What I could catch from the log at boot:
Log of 3 requests Capture.JPG
Log of 3 requests Capture.JPG (40.22 KiB) Viewed 5776 times

Don't know the clock resolution but I see only 10, 12, or 13 ticks between request and the "No Reply" message.
Is that long enough for a NTP response?

If I ping those IP's:
Ping response Capture.JPG
Ping response Capture.JPG (195.99 KiB) Viewed 5776 times
The ping times look reasonable to me.


I have seen this problem for the first time when I upgraded one unit to ESPEasy_v2.0.0-dev11 some time ago.
Could this, as a side effect, be related to dev11 improvements?
I see in dev11 release notes ..
- cleaned up RTC initialisation.
- large changes to wifi handling. code cleanup, more efficient connecting,

Is the code too fast now?

TD-er made a comment here:
wrong systime with DST / Timezone enabled #592 https://github.com/letscontrolit/ESPEasy/issues/592
perhaps the timeout of the NTP is also too short.
Any toughts?
Do more people have this problem?
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: NTP time-out too short?

#2 Post by TD-er » 17 Dec 2017, 02:20

I've made a pull request a few days ago, which should fix this: https://github.com/letscontrolit/ESPEasy/pull/639
The fix I made was to call NTP update every time the WiFi connection was made.
Of-course there is still the normal update interval.

There are also other WiFi related improvements for every controller service when no network is available.
Currently these services will timeout when there is no WiFi connection. These timeouts are longer than the interval to check again, so the ESP can't do much else and will look frozen when booted without known WiFi in the neighborhood.
Such behavior should also be fixed in that pull request.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: NTP time-out too short?

#3 Post by Shardan » 17 Dec 2017, 13:41

Hello,

this problem never occured here..

But:
I have my own NTP server running on my home controller box. As linux usually has its own NTP daemon running anyways (or it can be
installed easily if not) I use it to get internet time plus my own radio clock receiver together and distribute this to all
my computers, TV, Smartphone etc etc. This way i can block all ESP devices plus some "too curious" net devices from
internet completely.

As this time source resides in my local net there is only a very low delay, that works issue free.

Regards
Shardan
Regards
Shardan

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: NTP time-out too short?

#4 Post by papperone » 17 Dec 2017, 16:05

I use the standard "pool.ntp.org" with all my espeasy nodes, since R148 up to dev12 and I've never got this problem...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

Drum
Normal user
Posts: 300
Joined: 07 Feb 2016, 11:56

Re: NTP time-out too short?

#5 Post by Drum » 21 Dec 2017, 20:02

Shardan wrote: 17 Dec 2017, 13:41 Hello,

this problem never occured here..

But:
I have my own NTP server running on my home controller box. As linux usually has its own NTP daemon running anyways (or it can be
installed easily if not) I use it to get internet time plus my own radio clock receiver together and distribute this to all
my computers, TV, Smartphone etc etc. This way i can block all ESP devices plus some "too curious" net devices from
internet completely.

As this time source resides in my local net there is only a very low delay, that works issue free.

Regards
Shardan
Doh! Thanks for the reminder. I have to use cellular internet so I am always looking to cut any internet traffic.

grhhm
Normal user
Posts: 29
Joined: 23 Oct 2016, 20:15

Re: NTP time-out too short?

#6 Post by grhhm » 04 Mar 2018, 21:24

Sorry for digging this thread out.

I loaded ESP_Easy_v2.0-20180304b_normal (today's build) into Sonoff.
Configured NTP enabled with similar addresses as in original post (tried few addresses - same result).
My ESP8266 doesn't get the time from NTP. Seems NTP doesn't work exactly as described in the original post of this thread.

I thought to set up an NTP server in local network. I wonder if this could solve the problem.
Is anybody encountered the problem of NTP?

Thank you.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: NTP time-out too short?

#7 Post by TD-er » 04 Mar 2018, 22:21

There have recently been some changes in how the NTP works.
In previous builds, it kept retry'ing for a number of times and would stall the ESP.

Also the retry interval after that was way longer.

The current implementation is to retry every minute until it is set.
Also if the NTP lookup resolves to an IP that does not respond to ping, it will not even try.

Using pool.ntp.org will return a random IP on almost every DNS-request you make. (not sure about the change interval)
That may lead to some offline IP-hosts. In my tests, about 20% was offline. (tested about 15 minutes)

You could test with ntp.xs4all.nl or one provider more closer to you.
Make sure to test if it reacts to ping.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 62 guests