AWS Greengrass
Developer Guide

Test Communications

  1. Make sure that your computer and the AWS Greengrass core device are connected to the internet and are using the the same network. The following procedure can be used to confirm this:

    1. Determine the IP address of the AWS Greengrass core by running the following command:

      hostname -I
    2. From your computer, run the following command using the core's IP address (you can use Ctrl + C to halt the ping command):

      ping IP-address

      Output similar to the following indicates successful communication between the computer and the AWS Greengrass core device (note 0% packet loss):

                                    Successful ping command output.
  2. From the AWS IoT console, choose Settings, and note the value of Endpoint:

                            AWS IoT endpoint value.

    In the below, the endpoint value is indicated by AWS_IOT_ENDPOINT.

  3. Choose Greengrass, Groups, and then choose your group. Choose Settings, select Manually manage connection information, then choose View Cores for specific endpoint information. Choose your core, then Connectivity. Choose Edit and ensure your have only one Endpoint value which must be the IP address of your AWS Greengrass core device (for port 8883). Choose Update. This ensures that the script will connect to the correct AWS Greengrass core device IP address.

  4. Open two command-line windows on your computer (not the AWS Greengrass core device). One command-line window will be for the HelloWorld_Publisher device and the other for the HelloWorld_Subscriber device. Every time the following script ( is executed for the first time, the AWS Greengrass discovery service connects to the AWS Greengrass core. After a device has discovered the AWS Greengrass core and successfully connected to it, future messaging and operations can be executed locally (without the need for an internet connection).


    You can run the following command from the folder containing the file for detailed script usage information:

    python --help

    From the HelloWorld_Publisher device window, run the following commands:

    cd path-to-certs-folder python --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert publisher.cert.pem --key publisher.private.key --thingName HelloWorld_Publisher --topic 'hello/world/pubsub' --mode publish --message 'Hello, World! Sent from HelloWorld_Publisher'

    You should see output similar to the following:

                            Screenshot of the publisher output.


    If you get a message about unrecognized arguments, try changing the single quotes to double quotes for the message parameter.

  5. From the HelloWorld_Subscriber device window, run the following commands:

    cd path-to-certs-folder python --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert subscriber.cert.pem --key subscriber.private.key --thingName HelloWorld_Subscriber --topic 'hello/world/pubsub' --mode subscribe

    You should see the following output:

                            Screenshot of the subscriber output.

Notice that closing the HelloWorld_Publisher window halts additional messages from accruing in the HelloWorld_Subscriber window.

For information about the latest usage of, see the README file of the AWS IoT Device SDK for Python.