--- tag: api type: function name: state returns: type: int values: - value: '-4 : MQTT_CONNECTION_TIMEOUT' description: the server didn't respond within the keepalive time - value: '-3 : MQTT_CONNECTION_LOST' description: the network connection was broken - value: '-2 : MQTT_CONNECT_FAILED' description: the network connection failed - value: '-1 : MQTT_DISCONNECTED' description: the client is disconnected cleanly - value: '0 : MQTT_CONNECTED' description: the client is connected - value: '1 : MQTT_CONNECT_BAD_PROTOCOL' description: the server doesn't support the requested version of MQTT - value: '2 : MQTT_CONNECT_BAD_CLIENT_ID' description: the server rejected the client identifier - value: '3 : MQTT_CONNECT_UNAVAILABLE' description: the server was unable to accept the connection - value: '4 : MQTT_CONNECT_BAD_CREDENTIALS' description: the username/password were rejected - value: '5 : MQTT_CONNECT_UNAUTHORIZED' description: the client was not authorized to connect --- Returns the current state of the client. If a connection attempt fails, this can be used to get more information about the failure. All of the values have corresponding constants defined in PubSubClient.h.