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.
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)
msgmessage related to
qosquality of service level. The
retainflag specifies whether the message has to be kept after a subscriber receives it or not.
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.