Created
August 10, 2018 19:44
-
-
Save powersjcb/d48651da054c34d0c1d615011af2906c to your computer and use it in GitHub Desktop.
aws mqtt setup with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ref: https://github.com/eclipse/paho.mqtt.python#getting-started | |
from paho.mqtt.client import ssl | |
import paho.mqtt.client as mqtt | |
client = mqtt.Client() | |
def on_message(*args): | |
print(args) | |
def on_connect(*args): | |
client.publish(payload="1", qos=0, topic="test") | |
client.on_message = on_message | |
client.on_connect = on_connect | |
client.tls_set(certfile="apps/knox/priv/client-certificate.crt.pem", keyfile="./apps/knox/priv/client-private.key.pem", cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLS) | |
client.connect(host="a2vetinqu6twg7.iot.us-west-2.amazonaws.com", port=8883) | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment