You are viewing the documentation for AWS IoT Greengrass Version 1. AWS IoT Greengrass Version 2 is the latest major version of AWS IoT Greengrass. For more information about using AWS IoT Greengrass Version 2, see the AWS IoT Greengrass V2 Developer Guide.
Test communications
-
Make sure that your computer and the AWS IoT Greengrass core device are connected to the internet using the same network.
-
On the AWS IoT Greengrass core device, run the following command to find its IP address.
hostname -I
-
On your computer, run the following command using the IP address of the core. You can use Ctrl + C to stop the ping command.
ping
IP-address
Output similar to the following indicates successful communication between the computer and the AWS IoT Greengrass core device (0% packet loss):
Note If you're unable to ping an EC2 instance that's running AWS IoT Greengrass, make sure that the inbound security group rules for the instance allow ICMP traffic for Echo request messages. For more information, see Adding rules to a security group in the Amazon EC2 User Guide for Linux Instances.
On Windows host computers, in the Windows Firewall with Advanced Security app, you might also need to enable an inbound rule that allows inbound echo requests (for example, File and Printer Sharing (Echo Request - ICMPv4-In)), or create one.
-
-
Get your AWS IoT endpoint.
-
In the AWS IoT console
, in the navigation pane, choose Settings. -
Under Settings, make a note of the value of Endpoint. You use this value to replace the
AWS_IOT_ENDPOINT
placeholder in the commands in the following steps.Note Make sure that your endpoints correspond to your certificate type.
-
-
On your computer (not the AWS IoT Greengrass core device), open two command-line
(terminal or command prompt) windows. One window represents the HelloWorld_Publisher device and the other represents the HelloWorld_Subscriber device. Upon execution,
basicDiscovery.py
attempts to collect information on the location of the AWS IoT Greengrass core at its endpoints. This information is stored after the device has discovered and successfully connected to the core. This allows future messaging and operations to be executed locally (without the need for an internet connection).Note You can run the following command from the folder that contains the
basicDiscovery.py
file for detailed script usage information:python basicDiscovery.py --help
-
From the HelloWorld_Publisher device window, run the following commands.
-
Replace
path-to-certs-folder
with the path to the folder that contains the certificates, keys, andbasicDiscovery.py
. -
Replace
AWS_IOT_ENDPOINT
with your endpoint. -
Replace the two
publisher
instances with the hash in the file name for your HelloWorld_Publisher device.
cd
path-to-certs-folder
python basicDiscovery.py --endpointAWS_IOT_ENDPOINT
--rootCA root-ca-cert.pem --certpublisher
.cert.pem --keypublisher
.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, which includes entries such as
Published topic 'hello/world/pubsub': {"message": "Hello, World! Sent from HelloWorld_Publisher", "sequence": 1}
.Note If the script returns an
error: unrecognized arguments
message, change the single quotation marks to double quotation marks for the--topic
and--message
parameters and run the command again.To troubleshoot a connection issue, you can try using manual IP detection.
-
-
From the HelloWorld_Subscriber device window, run the following commands.
-
Replace
path-to-certs-folder
with the path to the folder that contains the certificates, keys, andbasicDiscovery.py
. -
Replace
AWS_IOT_ENDPOINT
with your endpoint. -
Replace the two
subscriber
instances with the hash in the file name for your HelloWorld_Subscriber device.
cd
path-to-certs-folder
python basicDiscovery.py --endpointAWS_IOT_ENDPOINT
--rootCA root-ca-cert.pem --certsubscriber
.cert.pem --keysubscriber
.private.key --thingName HelloWorld_Subscriber --topic 'hello/world/pubsub' --mode subscribeYou should see the following output, which includes entries such as
Received message on topic hello/world/pubsub: {"message": "Hello, World! Sent from HelloWorld_Publisher", "sequence": 1}
. -
Close the HelloWorld_Publisher window to stop messages from accruing in the HelloWorld_Subscriber window.
Testing on a corporate network might
interfere with connecting to the core. As a workaround, you can manually enter the
endpoint. This ensures that the basicDiscovery.py
script
connects to the correct IP address of the AWS IoT Greengrass core device.
To manually enter the endpoint
In the AWS IoT console, in the navigation pane, choose Greengrass, Classic (V1), Groups.
-
Under Greengrass groups, choose your group.
-
Choose Settings.
-
For Local connection detection, choose Manually manage connection information, and then choose View Cores for specific endpoint information.
-
Choose your core, and then choose Connectivity.
-
Choose Edit and make sure that you have only one endpoint value. This value must be the IP address endpoint for port 8883 of your AWS IoT Greengrass core device (for example,
192.168.1.4
). -
Choose Update.