Home/Support/Support Forum/XBee Cellular 3G HTTPS Failing

XBee Cellular 3G HTTPS Failing

0 votes
I have working micropython https scripts using urequests operating on my XBee3 LTE Cat 1 devices. When I move that code over to the 3g modem it fails with an 7005 EIO error.

HTTP code using sockets works. Are there issues with urequests on the 3G global modems?

What differences between the modems do I need to account for to rectify this error?

I attempted following instructions from here https://www.digi.com/resources/documentation/digidocs/PDFs/90001541.pdf

But I noted it was out of date since it references the old requests instead of the current urequests.
asked Apr 20 in XBee Cellular by deltav New to the Community (8 points)

Please log in or register to answer this question.

1 Answer

0 votes
Check the connection status before you try to send.
answered Apr 21 by mvut Veteran of the Digi Community (14,297 points)
Thanks but this isn't the problem.  I'm using the aws https example direct from the digi-upython-master.  It works on my 4g modem, and fails on my 3g modem.  There is some difference in the SSL library.  I have a feeling it has to do with hostname verification, but I cannot find the digi ssl.py source to confirm.  When I test ssl without certs on a different site it works, so I know that ssl itself is not the problem.

Code I'm using from the sample that works on 4g but fails on 3g below.  In my code I have populated the fill me in blanks.

# AWS endpoint parameters.
# TODO: replace with your account values.
HOST = b'FILL_ME_IN'        # ex: b'abcdefg1234567-ats'
REGION = b'FILL_ME_IN'      # ex: b'us-east-1'
THING_NAME = b'FILL_ME_IN'  # ex: b'IMEI_12345'

AWS_ENDPOINT = b'%s.iot.%s.amazonaws.com' % (HOST, REGION)

# SSL certificates.
SSL_PARAMS = {'keyfile': "/flash/cert/aws.key",
              'certfile': "/flash/cert/aws.crt",
              'ca_certs': "/flash/cert/aws.ca"}

def https_test(hostname=AWS_ENDPOINT, sslp=SSL_PARAMS):
    Tests the HTTPS connectivity with AWS. Sends an HTTP request to obtain the
    shadow of a thing and prints it.

    :param hostname: AWS hostname to connect to.
    :param sslp: SSL certificate parameters.

    # Connect to AWS.
    s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM,
    w = ussl.wrap_socket(s, **sslp)
    print("- Connecting to AWS... ", end="")
    w.connect((hostname, 8443))
    # Send HTTP request.
    print("- Sending shadow request for thing '%s'... " % THING_NAME, end="")
    w.write(b'GET /things/%s/shadow HTTP/1.0\r\n'
            b'Host: %s\r\n'
            b'\r\n' % (THING_NAME, hostname))
    # Read answer.
    print("- Waiting for data... ", end="")
    while True:
        data = w.read(1024)
        if data:
            print("- Received shadow for thing '%s':" % THING_NAME)
            print(64 * "-")
            print(str(data, 'utf-8'))
            print(64 * "-")
    # Disconnect.
    print("- Done")

print(" +-----------------------------------+")
print(" | XBee MicroPython AWS HTTPS Sample |")
print(" +-----------------------------------+\n")

conn = network.Cellular()

print("- Waiting for the module to be connected to the cellular network... ",
while not conn.isconnected():