Get started with MQTT on Python with Solace and Paho MQTT.
After creating a service on Solace Cloud, check under the "Connect" tab for the MQTT connection details:
Edit mqtt.py
with your username, password, and URL (omit the protocol, like wss://
and the port, which is a separate argument). There are some differences depending on which protocol you choose
- MQTT Host (
tcp://
)- Remove SSL:
client.tls_set(ca_certs=certifi.where())
- Remove SSL:
- WebSocket MQTT Host (
ws://
)- Remove SSL:
client.tls_set(ca_certs=certifi.where()) - Add Websocket transport to client:
client = mqtt.Client(transport='websockets')
- Remove SSL:
- Secured MQTT Host (
ssl://
)- Use SSL:
client.tls_set(ca_certs=certifi.where())
- Use SSL:
- WebSocket Secured MQTT Host (
wss://
)- Use SSL:
client.tls_set(ca_certs=certifi.where())
- Add Websocket transport to client:
client = mqtt.Client(transport='websockets')
- Use SSL: