Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

RTC ntp time server not working using DNS on static ip #9

Closed
@PiAir

Description

@PiAir

When using a static IP address (instead of DHCP), the ntp_sync() doesn't work when using the FQDN 'pool.ntp.org' although it does work when DHCP is used or when an IP-address is used.

>>> import os
>>> os.uname()
(sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='LoPy with ESP32', lorawan='1.0.0')
>>> wlan.ifconfig()
('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
>>> import machine
>>> rtc = machine.RTC()
>>> rtc.ntp_sync('pool.ntp.org', 3600)
>>> rtc.now()
(1970, 1, 1, 0, 2, 21, 96633, None)
>>> rtc.ntp_sync('128.199.44.119', 3600)
>>> rtc.now()
(2017, 5, 16, 6, 3, 44, 126771, None)

Also (I am adding it here in this issue because it might be caused by the same problem), socket.getaddrinfo() often returns '0.0.0.0' while using a static IP-address:

>>> wlan.ifconfig() ('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('122.175.14.128', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('16.88.252.63', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('0.0.0.0', 80))]
>>> socket.getaddrinfo('pool.ntp.org', 80)
[(2, 1, 0, '', ('80.87.252.63', 80))]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions