Determine whether an MQTT client is connected to a broker
Agent
Boolean — true
if the client is connected, otherwise false
This method allows your code to quickly determine whether an mqttclient object is currently connected to an MQTT broker: it will return true
if this is the case, otherwise false
.
Note If your code receives true
from mqttclient.isconnected(), we recommend you still wrap any communication calls, eg. sending a message, within a try... catch
structure. This is because the connection could fail while the agent is attempting to send the message.