MQTT5 is the recommended MQTT Client. It has many benefits over MQTT311 outlined in the MQTT5 User Guide
- MQTT5 PubSub
- MQTT5 Shared Subscription
- MQTT5 PKCS#11 Connect
- MQTT5 Custom Authorizer Connect
- MQTT5 Shadow
- MQTT5 Jobs
- MQTT5 Fleet Provisioning
- PubSub
- Basic Connect
- Websocket Connect
- PKCS#11 Connect
- PKCS#12 Connect
- Windows Certificate Connect
- Custom Authorizer Connect
- Cognito Connect
- X509 Connect
- Shadow
- Jobs
- Fleet Provisioning
First, install the aws-iot-devices-sdk-python-v2
with following the instructions from Installation.
Each sample README has instructions on how to run each sample with the same name as the sample itself. For example, the MQTT5 PubSub README is mqtt5_pubsub.md
and it can be run with the following:
# For Windows: replace 'python3' with 'python' and '/' with '\'
python3 mqtt5_pubsub.py --endpoint <endpoint> --cert <path to certificate> --key <path to private key>
All samples will show their options by passing in --help
. For example:
# For Windows: replace 'python3' with 'python' and '/' with '\'
python3 mqtt5_pubsub.py --help
Which will result in output showing all of the options that can be passed in at the command line, along with descriptions of what each does and whether they are optional or not.
To enable logging in the samples, you need to pass the --verbosity
as an additional argument. --verbosity
controls the level of logging shown. --verbosity
can be set to Trace
, Debug
, Info
, Warn
, Error
, Fatal
, or None
.
For example, to run MQTT5 PubSub sample with logging you could use the following:
# For Windows: replace 'python3' with 'python' and '/' with '\'
python3 mqtt5_pubsub.py <other arguments> --verbosity Debug