urequest.post gives me an OSError: Network card not available



  • Hi all!
    I simply like to post some measurement values to an influxdb.

    resp_data = "current,location={0} value={1}".format(location, irms)
    resp = urequests.post(db, data=resp_data)
    print("response: {}".format(resp.status_code))
    

    I'm using the lates urequests.py from micropython-lib.

    The error points me to line 56 of the urequests.py lib

    s = usocket.socket(ai[0], ai[1], ai[2])
    

    Someone else getting such an error?

    Cheers,
    Thomas



  • urequests.request("POST","http://IPADDRESS/api/v1/TOKEN/telemetry","{\"temperature\": 25.01,\"pressure\": 1.02}", None, {"Content-Type": "application/json"},None).text
    

    This worked for me to post to thingsboard

    after changing

    ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
    

    to

    ai = usocket.getaddrinfo(host, port)
    

    But when I got an error I had to power off to make it work again.

    urequests.py

    release='1.18.2.r7'



  • Ok...
    Digging a bit deeper into the problem.

    The request method in urequests.py uses the usocket.getaddrinfo method from the usocket lib to resolve the host ip.
    The given ip string is

    db = "http://xxx.xxx.xxx.xxx:8086/write?db=energy_db"
    

    and it is splittet correctly.
    The result of the usocket.getaddrinfo call

    ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
    

    gives the following list back:

    [(2, 1, 0, '', ('xxx.xxx.xxx.xxx', 8086))]
    

    The first list entry is the 'family'. Locking into the docs, FamilyType[2] is socket.AF_SIGFOX.
    The L01 doesn't have a SIGFOX modem. So, to try to open a socket with

    s = usocket.socket(ai[0], ai[1], ai[2])
    

    leads to the OSError: Network card not available.

    I'm using Pycom 1.20.0.rc13 [v1.9.4-94bb382] firmware. Is it probably a bug?

    Cheers,
    Thomas


Log in to reply
 

Pycom on Twitter