aws-solutions / smart-product-solution

The Smart Product Solution is a customer deployable reference architecture to help manufacturers to jumpstart development of innovative connected/smart product services.
Apache License 2.0
28 stars 19 forks source link

Error using mosquitto_pub on Raspberry Pi and playing simulator.js #5

Closed nbc-pet-task closed 4 years ago

nbc-pet-task commented 4 years ago

I am watching and following a Youtube video and tutorial. https://www.youtube.com/watch?v=kgXYO5Iqklo&t=1894s https://docs.aws.amazon.com/solutions/latest/smart-product-solution/deployment.html

However I got a issue follow..

pi@raspberrypi:~/aws_SmartProductSolutionsSample $ mosquitto_pub --cafile root.cert --cert deviceCertAndCACert.crt --key deviceCert.key -p 8883 -q 1 -t foo/bar -i anyclientID --tls-version tlsv1.2 -m "Hello" -d -h a1inzd6lczlz6f-ats.iot.us-east-1.amazonaws.com Client anyclientID sending CONNECT OpenSSL Error: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Error: Success

So I can't running simulator.js below.. image

Did I do something wrong?

nbc-pet-task commented 4 years ago

I did reinstall mosquitto latest version. so I got same message in your Youtube video.

Installed lib my packages are..

openssl version OpenSSL 1.0.1t 3 May 2016 aws-cli/1.18.20 Python/2.7.9 Linux/4.9.35-v7+ botocore/1.15.20 mosquitto version 1.6.8

$ mosquitto_pub --cafile root.cert --cert deviceCertAndCACert.crt --key deviceCert.key -p 8883 -q 1 -t foo/bar -i anyclientID --tls-version tlsv1.2 -m "Hello" -d -h a1inzd6lczlz6f-ats.iot.us-east-1.amazonaws.com Client anyclientID sending CONNECT Error: The connection was lost.

But when I run simulator I got same issue.

~/simulator $ sed -i -e 's/REPLACE_HERE/123456789-abcde/g' config.js ~/simulator $ npm start

smart-product-demo-simulator@0.0.1 start /home/pi/simulator node simulator.js

Connecting to AWS IoT...

????? Stopping........

nbc-pet-task commented 4 years ago

Um.. I tried that make key and certificate on AWS IoT web console. And then I copied files to Raspberry Pi. also attached policy & thing using web console.

At result... Working well!! :)

beomseoklee commented 4 years ago

@nbc-pet-task I'm sorry for your inconvenience. I think the implementation guide one step to change HOSTNAME to the actual AWS IoT endpoint in config.js file.

sed -i -e 's/HOSTNAME/'$HOST'/' config.js

HOST can be a1inzd61czlz6f-ats.iot.us-east-1.amazonaws.com in your case. I'm happy that you succeeded to connect to the simulator, but I would like to make sure that you have changed host configuration.

nbc-pet-task commented 4 years ago

Just hard coding [host] in config.js file :)

thanks!!