Folks,
I have tried continuously for the past week to connect my Digi Xbee3 Cellular LTE-M to the AWS Console. I think my problem is with the SSL certificate that is causing the socket.connect function to time out - but that is just a guess. I have reviewed other posts with a similar issue and tried all the recommendations: (removing -ats from the host name; using the Symantec legacy certificate, using the Starfield certificate, using new aws certificates, etc.). I keep getting the following error when using the micropython test code (aws-https.py) found at https://github.com/digidotcom/xbee-micropython:
MicroPython v1.9.4-927-g7565eb7 on 2018-11-08; XBC LTE-M/NB-IoT Global with EFR32MG
Type âhelp()â for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
1=== import usocket, ussl, time, network
2=== host = bâa11y05y0u5faakâ
3=== region = bâus-west-2â
4=== thing_name = bâSWR_TestSensor_1â
5=== aws_endpoint = bâ%s.iot.%s.amazonaws.comâ % (host, region)
6=== ssl_params = {âkeyfileâ: â/flash/cert/aws.keyâ,
7=== âcertfileâ: â/flash/cert/aws.crtâ,
8=== âca_certsâ: â/flash/cert/cert.caâ}
9=== conn = network.Cellular()
10=== while not conn.isconnected():
11=== print(âwaiting for network connectionâŠâ)
12=== time.sleep(4)
13=== print(ânetwork connectedâ)
14=== def https_test(hostname=aws_endpoint, sslp=ssl_params):
15=== s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM, usocket.IPPROTO_SEC)
16=== s.setblocking(False)
17=== w = ussl.wrap_socket(s, **ssl_params)
18=== print(âconnectingâŠâ)
19=== w.connect((hostname, 8443))
20=== print(âconnectedâ)
21=== print(âsending requestâ)
22=== w.write(bâGET /things/%s/shadow HTTP/1.0
Host: %s
â % (thing_name, hostname))
23=== print(âwaiting for dataâŠâ)
24=== while True:
25=== data = w.read(1024)
26=== if data:
27=== print(str(data, âutf-8â))
28=== break
29=== w.close()
30=== print(âDONEâ)
31=== https_test()
32===
network connected
Traceback (most recent call last):
File ââ, line 31, in
File ââ, line 17, in https_test
Likewise, I get the following error codes when using the same source for testing an mqtt connection (aws-publish.py):
MicroPython v1.9.4-927-g7565eb7 on 2018-11-08; XBC LTE-M/NB-IoT Global with EFR32MG
Type âhelp()â for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
1=== from umqtt.simple import MQTTClient
2=== import time, network
3=== host = bâa11y05y0u5faakâ
4=== region = bâus-west-2â
5=== aws_endpoint = bâ%s.iot.%s.amazonaws.comâ % (host, region)
6=== ssl_params = {âkeyfileâ: â/flash/cert/aws.keyâ,
7=== âcertfileâ: â/flash/cert/aws.crtâ,
8=== âca_certsâ: â/flash/cert/aws.caâ}
9=== conn = network.Cellular()
10=== while not conn.isconnected():
11=== print(âwaiting for network connectionâŠâ)
12=== time.sleep(4)
13=== print(ânetwork connectedâ)
14=== def publish_test(clientId=âSWR_TestSensor_1â, hostname=aws_endpoint, sslp=ssl_params):
15=== c = MQTTClient(clientId, aws_endpoint, ssl=True, ssl_params=sslp)
16=== print(âconnectingâŠâ)
17=== c.connect()
18=== print(âconnectedâ)
19=== print(âpublishing messageâŠâ)
20=== c.publish(âsample/xbeeâ, â{âmessageâ: âAWS Sample Messageâ}â)
21=== print(âpublishedâ)
22=== c.disconnect()
23=== print(âDONEâ)
24=== publish_test()
network connected
connectingâŠ
Traceback (most recent call last):
File ââ, line 24, in
File ââ, line 17, in publish_test
File â/flash/lib/umqtt/simple.pyâ, line 72, in connect
OSError: [Errno 7005] EIO
I am new to using certificates but it seems to be where the problem is. Has anyone experienced similar issues and can provide some guidance? Or is there something in my code that doesnât look quite right? Thanks in advance!
Jon