I am having issues connecting an XBee Cellular LTE-M to the AWS console. If appears to me that there is a certificate issue that is causing the socket.connect function to time out. I have reviewed the few other questions on this topic and have tried several of the fixes, but none seem to work. To date, I have:
1) removed the -ats suffix from the host name
2) tried the Starfield Root certificate as suggested in the Digi Cellular User guide
3) tried the Legacy Symantec Root certificate as suggested in this forum
4) tried the AWS Root certificates as they suggest.
Nothing seems to work. The micro-python code runs, connects to the cellular network, then grinds away until timing out with errors. I have tried both the https_test and the MQTT _publish programs with no success. Here is the code for the aws-https.py and aws-publish.py programs found at (https://github.com/digidotcom/xbee-micropython/blob/master/samples/cellular/aws/) along with the associated errors.
The HTTPS Code:
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/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 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()
network connected
connectingâŚ
Traceback (most recent call last):
File ââ, line 31, in
File ââ, line 19, in https_test
OSError: [Errno 7005] EIO
And the MQTT Publish code:
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()
25===
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
Note than line 72 in the simple.py module is as follows: self.sock.connect((self.server, self.port))
So, I have no idea how to proceed. I think the code is right, since the only changes from the stock code on Github is that I added the unique identifier for the Xbee and the certificates (which were downloaded to the Xbee prior to execution. This leads me to believe that the certificates arenât being accepted. Any assistance on how to move forward would be greatly appreciated. Thanks!
Jon