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

    Sporadic [Errno 113] EHOSTUNREACH from HTTP server

    Scheduled Pinned Locked Moved WiPy 2&3
    4 Posts 2 Posters 1.7k Views 3 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.
    • C Offline
      crankshaft
      last edited by crankshaft

      I have a simple http server, just one connection from the local area network, nothing fancy.

      I am unable to keep the server running permanently, normally within an hour it will die with : [Errno 113] EHOSTUNREACH

      Having googled this, it appears that most people say it is DNS lookup related, however there is no DNS lookup involved and it is the client connecting to the server on an ip address and not the server trying to contact another hostname.

      Any suggestions on how I can trap / prevent this error as I I am all out of ideas !

      This is not all of the codse with the imports etc, but it's the most important part:

      def close():
        global conn
        conn.sendall('\n')
        conn.close()
      
      while True:
        try:
          global conn
          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          # sock.settimeout(5)
          sock.bind(('', 80))
          sock.listen(1)
        
          while True:
            conn, addr = sock.accept()
            raw = conn.recv(1024).decode('UTF-8')
            if not raw:
              print('Null Request.')
              close()
            else:
              print(addr,'OK')
              conn.sendall('<h1>Hello</h1>\n')
              close()
            gc.collect()
              
        except Exception as e:
          print(e)
      
      L 1 Reply Last reply Reply Quote 0
      • C Offline
        crankshaft
        last edited by

        I suspect this maybe either related to the wlan power saving or the conversion of usocket library,

        The "EHOSTUNREACH" error appears to be an exception that is thrown when the socket is configured as a client and attempts to connect to another host, however in this application the socket is configured as a server NOT a client ?!

        1 Reply Last reply Reply Quote 0
        • C Offline
          crankshaft
          last edited by

          Ahh, just spotted this:

          Traceback (most recent call last):
            File "", line 1, in e�li�p��t��x��|��}e�}i�}h�}c�|��}a�}��}��|��}a�}��}b�|f�}d�}��}b�|i�}d�}��}e�}i
            File "dev.py", line 58, in <module>
            File "dev.py", line 56, in z
            File "www/server.py", line 144, in run
          OSError: [Errno 113] EHOSTUNREACH
          

          dev.py and server.py are my files, but what is file""

            File "", line 1, in e�li�p��t��x��|��}e�}i�}h�}c�|��}a�}��}��|��}a�}��}b�|f�}d�}��}b�|i�}d�}��}e�}i
          

          is

          1 Reply Last reply Reply Quote 0
          • L Offline
            livius @crankshaft
            last edited by

            @crankshaft
            i am in the same position as you
            OSError: [Errno 113] EHOSTUNREACH
            but only in current firmware
            other wipy with 1.5.0 work ok many days..
            but with 1.5.1 above error

            think about people first, then computers

            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