Troubleshooting problems with the sample app - AWS IoT Core

Troubleshooting problems with the sample app

If you encounter an error when you try to run the sample app, here are some things to check.

Check the certificate

If the certificate is not active, AWS IoT will not accept any connection attempts that use it for authorization. When creating your certificate, it's easy to overlook the Activate button. Fortunately, you can activate your certificate from the AWS IoT console.

To check your certificate's activation
  1. In the AWS IoT console, in the left menu, choose Secure, and then choose Certificates.

  2. In the list of certificates, find the certificate you created for the exercise and check its status in the Status column.

    If you don't remember the certificate's name, check for any that are Inactive to see if they might be the one you're using.

    Choose the certificate in the list to open its detail page. In the detail page, you can see its Create date to help you identify the certificate.

  3. To activate an inactive certificate, from the certificate's detail page, choose Actions and then choose Activate.

If you found the correct certificate and it's active, but you're still having problems running the sample app, check its policy as the next step describes.

You can also try to create a new thing and a new certificate by following the steps in Create a thing object. If you create a new thing, you will need to give it a new thing name and download the new certificate files to your device.

Check the policy attached to the certificate

Policies authorize actions in AWS IoT. If the certificate used to connect to AWS IoT does not have a policy, or does not have a policy that allows it to connect, the connection will be refused, even if the certificate is active.

To check the policies attached to a certificate
  1. Find the certificate as described in the previous item and open its details page.

  2. In the left menu of the certificate's details page, choose Policies to see the policies attached to the certificate.

  3. If there are no policies attached to the certificate, add one by choosing the Actions menu, and then choosing Attach policy.

    Choose the policy that you created earlier in Create AWS IoT resources.

  4. If there is a policy attached, choose the policy tile to open its details page.

    In the details page, review the Policy document to make sure it contains the same information as the one you created in Create an AWS IoT policy.

Check the command line

Make sure you used the correct command line for your system. The commands used on Linux and macOS systems are often different from those used on Windows systems.

Check the endpoint address

Review the command you entered and double-check the endpoint address in your command to the one in your AWS IoT console.

Check the file names of the certificate files

Compare the file names in the command you entered to the file names of the certificate files in the certs directory.

Some systems might require the file names to be in quotes to work correctly.

Check the SDK installation

Make sure that your SDK installation is complete and correct.

If in doubt, reinstall the SDK on your device. In most cases, that's a matter of finding the section of the tutorial titled Install the AWS IoT Device SDK for SDK language and following the procedure again.

If you are using the AWS IoT Device SDK for JavaScript, remember to install the sample apps before you try to run them. Installing the SDK doesn't automatically install the sample apps. The sample apps must be installed manually after the SDK has been installed.