Skip to content

Instantly share code, notes, and snippets.

@powersjcb
Created August 10, 2018 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save powersjcb/d48651da054c34d0c1d615011af2906c to your computer and use it in GitHub Desktop.
Save powersjcb/d48651da054c34d0c1d615011af2906c to your computer and use it in GitHub Desktop.
aws mqtt setup with python
# 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