Sporadic [Errno 113] EHOSTUNREACH from HTTP server



  • 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)
    


  • @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



  • 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



  • 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 ?!


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.