ETIMEOUT using ntptime.py ESP32 #10632
-
After reading this discussion: Even making this correction I was still getting ETIMEOUT errors, about By putting a try/except around every function call I ended up with errors with this call: try:
msg = s.recv(48)
print (f'NTP response: {msg}')
utime.sleep_ms(100)
except OSError as e:
try:
with open('errors.txt', 'a') as outfile:
outfile.write('did NOT recv the msg' + '\n')
outfile.write('error = ' + str(e) + '\n')
print (f'wait 60 seconds before doing a machine.reset()')
utime.sleep_ms(100)
machine.reset()
except OSError:
pass I am currently using Any suggestions for testing and/or improving the success-rate are appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
By default the timeout is set to 1s. It can be increased as per the code comment, but there is a question mark over the point of having a time signal that arrives after a long delay. In my experience timeouts are fairly common. It just depends on your internet connection. |
Beta Was this translation helpful? Give feedback.
-
If you want reasonably accurate network time on a uPython device, you need to either implement a full NTP client, or point the current implementation to some known-good "zero" delay source. I run ntpd on my router, letting it do all the heavy lifting from four NTP sources, and then set ntptime host to the router. (I have also used chronyd on one of my servers for the same purpose, but like the router-based solution better.)
|
Beta Was this translation helpful? Give feedback.
-
@efahl Your response about I have an ancient Raspberry Pi running 24/7. It runs standard Raspbian and serves as a Mosquitto broker. Without any configuration changes the following worked on a Pico W: ntptime.host="192.168.0.10" # Address of the Pi
ntptime.time() I proved that this really was working by invalidating the IP - the query then timed out. |
Beta Was this translation helpful? Give feedback.
By default the timeout is set to 1s. It can be increased as per the code comment, but there is a question mark over the point of having a time signal that arrives after a long delay.
In my experience timeouts are fairly common. It just depends on your internet connection.