Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Problem binding sock for captive portal

    Scheduled Pinned Locked Moved WiPy 2&3
    4 Posts 2 Posters 1.4k Views 2 Watching
    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.
    • K Offline
      KMcLoud
      last edited by

      I've got a WiPy serving html over http just fine on port 80 in AP mode.

      However, I'm also trying to set up a captive portal so that any dns request within the WiPy's broadcasted network is redirected to the configuration page.

      When I go to bind the socket to port 53, the execution just hangs forever. I simplified the code down to:

      import socket
      import network
      
      ap = network.WLAN()
      ap.init(network.WLAN.AP, ssid='dns test')
      
      def start():        
          udps = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
          udps.setblocking(False)
          udps.settimeout(10)#seconds
          print('just before bind')
          udps.bind(('',53))
          print('just after bind')
      

      when you call start() from the repl, you get:

      
      >>> start()
      just before bind
      
      

      ...the repl never returns

      The bind call on port 80 for my http setup works just fine and returns quickly.

      Any idea what I'm doing wrong here?

      1 Reply Last reply Reply Quote 0
      • X Offline
        Xykon administrators
        last edited by

        My guess would be that the RTOS running underneath micropython is using the port to resolve DNS requests in AP mode... not sure if that was done recently to fix the reverse DNS lookup timeout telnet bug in MacOS or if this was working like that from the start.

        In STA mode your code works without problems...

        Christian Ehlers

        1 Reply Last reply Reply Quote 0
        • K Offline
          KMcLoud
          last edited by

          is it possible to control that behavior from micropython?

          1 Reply Last reply Reply Quote 0
          • X Offline
            Xykon administrators
            last edited by

            Not that I can see from looking at the current documentation.

            Christian Ehlers

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom