Generic MQTT error.
Protocol versions mismatch between client and server.
The client identifier is not correct.
The MQTT server is not reachable or does not respond.
Wrong username and/or password specified for MQTT connection.
The username specified for MQTT connection is not authorized to establish the connection, even it credentials are correct.
The publish method has timeout waiting for ack from borker when
qos > 0 and
timeout > 0.
The publish method failed with an error that does not match any of the previous exceptions.
MQTT(host, client_id, username="", password="", port=1883, clean_session=True, keepalive=60, reconnect_after=5000, network_timeout=6000, ctx=())
hostis the server hostname or IP address to connect to and to subscribe for messages.
client_idis "our" client identification.
usernameis the username used for authentication.
passwordis the passoword user for the authentication.
portis the server TCP/UDP port to connect to. Default: 1883.
clean_sessionif True the MQTT is cleaned. Default: True.
keepaliveis the time period in seconds to send a keep-alive to the server.
reconnect_afteris the auto reconnect time in milliseconds.
network_timeoutis the timeout in milliseconds for the connections. Currently unused.
ctxis the SSL context. See the description in HTTP protocol page
publish(topic, msg, qos=0, retain=False, timeout=0)
msgmessage related to
qosquality of service level. The
retainflag specifies whether the message has to be kept after a subscriber receives it or not. The
timeoutspecifies the time in milliseconds to wait for an acknowledgement form the broker when
qos> 0; when
qos= 0, the
timeoutis ignored. If the acknowledgement is not received by the
MQTTPublishTimeoutexception is raised.
on(sub, callback, qos=1)
callbackfunction for the
qosquality of service level.
- first connection since system startup, in milliseconds.
- last connection since system startup, in milliseconds.
- last disconnection since system startup, in milliseconds.
- number of disconnections.
- number of received data.
- number of received messages.
- number of sent data.
- number of sent messages.