Open racheliurui opened 4 years ago
Just found the issue with setting the endpoint, modified the https://github.com/aws-samples/aws-iot-events-accelerators/blob/2905825720d9dd252d8d1878f5b363a60b87d054/integratingmachinelearning/docker/simulated_motor.py#L27
The endpoint here should be the thing's endpoint not static data.iot.[region].amazon.aws.com. For me it's something like
xxxxxxxxx-ats.iot.us-east-1.amazonaws.com
But after that, still I get SSL certificate error,
aws-iotevents-iml-simulatedmotor | Endpoint :a2rizlo4ii9h59-ats.iot.us-east-1.amazonaws.com
aws-iotevents-iml-simulatedmotor | mqttc.connect()
aws-iotevents-iml-simulatedmotor | File "/usr/local/lib/python2.7/site-packages/AWSIoTPythonSDK/MQTTLib.py", line 513, in connect
aws-iotevents-iml-simulatedmotor | return self._mqtt_core.connect(keepAliveIntervalSecond)
aws-iotevents-iml-simulatedmotor | File "/usr/local/lib/python2.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 196, in connect
aws-iotevents-iml-simulatedmotor | self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
aws-iotevents-iml-simulatedmotor | File "/usr/local/lib/python2.7/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 223, in connect_async
aws-iotevents-iml-simulatedmotor | raise e
aws-iotevents-iml-simulatedmotor | ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)
OK, SSL issue also found the reason, the root CA should be
https://www.amazontrust.com/repository/AmazonRootCA1.pem
Please instead of providing the rootCA.pem under certs, use curl to get the it.
Now it all works.
aws-iotevents-iml-simulatedmotor | Message Published {"motorID": "AWS98765", "TT10": 57, "PTO1": 21, "FTO1": 172, "TT08": 82, "TT09": 68, "TT04": 27, "TT05": 55, "TT06": 52, "TT07": 79, "TT01": 5, "TT02": 65, "TT03": 83, "motorType": "Pump_GN12345"}
aws-iotevents-iml-simulatedmotor | Message Published {"motorID": "AWS98765", "TT10": 39, "PTO1": 30, "FTO1": 161, "TT08": 34, "TT09": 27, "TT04": 28, "TT05": 59, "TT06": 99, "TT07": 65, "TT01": 6, "TT02": 66, "TT03": 79, "motorType": "Pump_GN12345"}
aws-iotevents-iml-simulatedmotor | Message Published {"motorID": "AWS98765", "TT10": 31, "PTO1": 26, "FTO1": 202, "TT08": 51, "TT09": 61, "TT04": 86, "TT05": 61, "TT06": 71, "TT07": 45, "TT01": 7, "TT02": 77, "TT03": 78, "motorType": "Pump_GN12345"}
aws-iotevents-iml-simulatedmotor | Message Published {"motorID": "AWS98765", "TT10": 33, "PTO1": 31, "FTO1": 234, "TT08": 72, "TT09": 67, "TT04": 51, "TT05": 82, "TT06": 73, "TT07": 66, "TT01": 6, "TT02": 61, "TT03": 20, "motorType": "Pump_GN12345"}
aws-iotevents-iml-simulatedmotor | Message Published {"motorID": "AWS98765", "TT10": 78, "PTO1": 28, "FTO1": 186, "TT08": 21, "TT09": 21, "TT04": 44, "TT05": 99, "TT06": 20, "TT07": 83, "TT01": 12, "TT02": 53, "TT03": 42, "motorType": "Pump_GN12345"}
In summary, 2 places need to be modified to make the sample work, 1) the MQTT endpoint should be the thing's endpoint, not just static region name. 2) the rootCA.pem should curl from the official website, not using the hard coded one from the cert folder.
============ I am trying to run through the sample, I haven changed region to us-east-1
1) certificate for the thing has been created and copied to certs folder under docker before run docker command 2) after cfn creation I can see the thing is created successfully with full access to publish message. 3) no firewall for outbound 8883 from the mac
The Cloudside configuration all works for me, but the client simulation docker image gave me exception as below,