http requests do not resolve local dns



  • Using the http demo project on a M5 Core works fine,
    also querying my internet servers work fine.
    When trying to send http GET requests to my local servers, it works with the IP-adress only, not with the local dns as it works in the browser.
    So my question is, how does "urequests.request" resolve the DNS to an IP to do the connection ? It should use the DNS-server from the WiFi-Connection and not some internet facing server such as google or 1.1.1.1.

    Not all apllications use servers in the cloud! There are also local applications or in company networks !!

    I've seen the same issue using the python function socket.getaddrinfo
    this queries also an internet DNS server and not the local ones.

    Anybody knows a solution ?



  • Hello @sgu

    I've just tried the provided HTTP example (UIFlow online) and in my case it is using the local DNS server IP address which it gets from the DHCP server. Have you checked your DHCP server settings?

    What do you get when you print wlan.ifconfig(). The last IP address is the DNS.

    Thanks
    Felix



  • Thanks a lot for your test.
    My code also uses the wlan.ifconfig this way you can see the ipaddress, gateway and DNS.

    I've upgraded the M5 Core to latest Firmware V1.10.4 and I still can reproduce the error that it does not work with local DNS.
    Even if the M5 Core would use the firewall as the DNS server, this would work as well.

    Additionally found another bug:

    when using the Online Ui Flow and adding the block for getting ifconfig 0_1662492113133_c2635e39-6ea4-46b9-8183-da8df125edec-image.png

    then it creates a runtime error. The cause is:

    blockly adds text "wlan.ifconfig"
    0_1662492206969_0ce61608-6624-48dd-a940-a1daddf22503-image.png

    but it must be "wlan_sta.ifconfig" and then it runs
    0_1662492322169_6774c2c6-3268-4eaa-bc96-e3109ce82096-image.png

    The same issue als on a M5 Core2 it does not show an error message, just the screen stay white :-(
    what a poor software quality.



  • 0_1662527911433_Screenshot 2022-09-07 at 06.18.13.png

    The following code snippet has been working fine for me and uses a local DNS aka the router.

    The reason that

    label1.setText(str(wlan.ifconfig()))
    

    Is failing is because you haven't told the code to create a station and activate the interface as shown in my image.



  • @ajb2k3
    This looks very nice, I'll try it out.
    Thanks for your post !