Answer the question
In order to leave comments, you need to log in
What should I do to connect to the mqtt.cloud.yandex.net MQTT broker in Python?
I am writing a Python program to work with an MQTT broker.
First, I connect via port 1883 to the broker.emqx.io broker:
mqtt_broker = "broker.emqx.io"
mqtt_broker_port = 1883
mqtt_client_id = f"ozna_ds_publisher_{random.randint(0, 1000000)}"
mqtt_keepalive = 5 * 60
client = mqtt_client.Client(mqtt_client_id)
client.connect(mqtt_broker, mqtt_broker_port, keepalive=mqtt_keepalive)
mqtt_broker = "mqtt.cloud.yandex.net"
mqtt_broker_port = 8883
mqtt_client_id = f"ozna_ds_publisher_{random.randint(0, 1000000)}"
mqtt_keepalive = 5 * 60
client = mqtt_client.Client(mqtt_client_id)
client.tls_set("C:/Works/mqtt-rest-bridge/cert.pem", tls_version=ssl.PROTOCOL_TLSv1_2)
client.tls_insecure_set(True)
client.connect(mqtt_broker, mqtt_broker_port, keepalive=mqtt_keepalive)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question