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

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

    Scheduled Pinned Locked Moved LoPy
    5 Posts 3 Posters 335 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.
    • T Offline
      Thosch42
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • T Offline
        Thosch42
        last edited by

        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

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

          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'

          S 2 Replies Last reply Reply Quote 0
          • S Offline
            samith wijerathna @KenM
            last edited by

            @KenM Could you please share the python code I am trying to send data to thingsboard via Gpy LTE Nb network.

            1 Reply Last reply Reply Quote 0
            • S Offline
              samith wijerathna @KenM
              last edited by

              @KenM said in urequest.post gives me an OSError: Network card not available:

              api/v1/

              thanks lot .it is working...

              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