🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    http requests do not resolve local dns

    FAQS
    3
    5
    5.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sgu
      last edited by

      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 ?

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        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

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • S
          sgu
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3
            last edited by

            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.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            S 1 Reply Last reply Reply Quote 0
            • S
              sgu @ajb2k3
              last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post