After we write a program, comp-demo.js, we can execute this program. Now you can run the program. Type this command:
$ node comp-demo.js
Make sure all certificate files are on the same path with comp-demo.js. If successful, you should see the connected state and receive the incoming message:
You can also verify on AWS IoT Management Console about this transaction: