usocket getaddrinfo issues



  • Hi,

    could someone explain to me how can "usocket.getaddrinfo" retrieve the IP number ... if there is no internet connection on the devices? ... before it is ...

    ### boot.py -- run on boot-up
    import os
    from machine import UART
    uart = UART(0, 115200)
    os.dupterm(uart)
    
    import machine
    
    import usocket
    import time
    
    # Delay between each event
    DELAY = 5
    
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    time.sleep(DELAY)
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    time.sleep(DELAY)
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    time.sleep(DELAY)
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    time.sleep(DELAY)
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    time.sleep(DELAY)
    print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    
    machine.main('')
    

    Here is the log:

    ('10.0.0.0', 80)
    ('72.25.15.128', 80)
    ('72.25.15.128', 80)
    ('72.25.15.128', 80)
    ('72.25.15.128', 80)
    ('72.25.15.128', 80)
    could not open file '' for reading
    Pycom MicroPython 1.18.1.r4 [v1.8.6-849-dfa1176] on 2018-11-12; FiPy with ESP32
    Type "help()" for more information.
    >>>
    

    Here is the funny shit ... I'm manually executing the same command on the REPL ... and I get waayy different results:

    Pycom MicroPython 1.18.1.r4 [v1.8.6-849-dfa1176] on 2018-11-12; FiPy with ESP32
    Type "help()" for more information.
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('74.57.145.1', 80)
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('200.138.156.1', 80)
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('41.244.171.1', 80)
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('232.134.184.1', 80)
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('163.13.199.1', 80)
    >>> print(usocket.getaddrinfo("api.wia.io", 80)[0][-1])
    ('109.23.213.1', 80)
    >>>
    

    And if you do a ping on your computer ... you get the real IP number ...

    [temp @ isx-deft : ~ ]  $ ping api.wia.io
    PING api.wia.io (52.17.209.228): 56 data bytes
    64 bytes from 52.17.209.228: icmp_seq=0 ttl=41 time=44.379 ms
    64 bytes from 52.17.209.228: icmp_seq=1 ttl=41 time=74.067 ms
    64 bytes from 52.17.209.228: icmp_seq=2 ttl=41 time=49.937 ms
    64 bytes from 52.17.209.228: icmp_seq=3 ttl=41 time=49.050 ms
    ^C
    --- api.wia.io ping statistics ---
    4 packets transmitted, 4 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 44.379/54.358/74.067/11.573 ms
    

    So my question is ... how the crapy can usecket.getaddrinfo even produce an IP number with out have an internet connection ... and the next thing, how can it even produce different IP numbers when executed on the REPL ... compared to in-line-code be??



  • @combaindeft Thanks for the info. I've passed it on to the team who are actively looking into the reported issues around DNS resolution.



  • @paul-thornton said in usocket getaddrinfo issues:

    @combaindeft Thanks. Looks like we clearly still have some issues with this. Ill let the appropriate people know.

    So I had a talk with our operator (Telia) here in sweden. And thay say:

    "Having EPS bearer that support PPP does not work (it's not in the 4G, LTE-M, or NB-IoT specs) - however, software / OS uses PPP against the devices to get the IP address it received from The network is a solution that the device manufacturer you use must answer. It's all about drivers and software."

    "Making a DNS resolve should not be a problem. However, the devic must be "ready" to receive data, which is then read out."



  • @combaindeft Thanks. Looks like we clearly still have some issues with this. Ill let the appropriate people know.



  • @paul-thornton I have, and still getting the issue :-(



  • The firmware will cache DNS responses to avoid the latency on each additional request.

    There is also a known bug at the older firmwares where seemingly random IP's are returned whilst disconnected from the internet.

    It seems you've been hit by a case of both cached data and the random response bug.

    you should no longer see the random results if you upgrade to either:
    https://forum.pycom.io/topic/4099/new-firmware-release-candidate-v1-20-0-rc0/21
    or
    v1.18.1.r6


Log in to reply
 

Pycom on Twitter