Class MqttConnectException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.mqtt4j.hato.MqttException
org.mqtt4j.hato.MqttConnectException
- All Implemented Interfaces:
Serializable
A connection attempt failed. A broker refusal carries its reason code; transport failures
and deadline expiry carry a cause instead. An MQTT 5.0 broker can also explain its refusal in
reasonString() and, with ReasonCode.USE_ANOTHER_SERVER or ReasonCode.SERVER_MOVED,
name another server in serverReference(), which the client does not follow. Locally
detected packet failures carry MqttProtocolException as their cause, leaving reasonCode()
empty.
An attempt that discarded a broker session without local state and then finds a session
again, as MqttClient.connect() describes, fails with neither a reason code nor a cause,
as does an attempt that MqttClient.disconnect() or MqttClient.close() withdraws. A
failure while closing the connection that found the session is attached as a suppressed
exception. If the client's TimerScheduler fails meanwhile,
that failure is the cause instead, and the refusal is attached as a suppressed exception.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMqttConnectException(String message) A failure with neither a reason code nor a cause.MqttConnectException(String message, Throwable cause) A failure with a cause instead of a reason code, such as a transport failure or deadline expiry.MqttConnectException(String message, ReasonCode reasonCode) A broker refusal without an explanation or a server reference.MqttConnectException(String message, ReasonCode reasonCode, @Nullable String reasonString, @Nullable String serverReference) A broker refusal with the explanation and the server reference that the broker sent, if any. -
Method Summary
Modifier and TypeMethodDescriptionReturns the broker's refusal reason, or empty when the attempt failed locally.Returns the broker's explanation of its refusal for people diagnosing it, or empty when it sent none, as MQTT 3.1.1 brokers never do.Returns the server that the broker named for the client to use instead, or empty when it named none.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MqttConnectException
A failure with neither a reason code nor a cause.- Parameters:
message- the detail message
-
MqttConnectException
A broker refusal without an explanation or a server reference.- Parameters:
message- the detail messagereasonCode- the broker's refusal reason
-
MqttConnectException
public MqttConnectException(String message, ReasonCode reasonCode, @Nullable String reasonString, @Nullable String serverReference) A broker refusal with the explanation and the server reference that the broker sent, if any.- Parameters:
message- the detail messagereasonCode- the broker's refusal reasonreasonString- the broker's explanation, or null when it sent noneserverReference- the server that the broker named, or null when it named none
-
MqttConnectException
-
-
Method Details
-
reasonCode
Returns the broker's refusal reason, or empty when the attempt failed locally.- Returns:
- the broker's refusal reason, or empty when the attempt failed locally
-
reasonString
Returns the broker's explanation of its refusal for people diagnosing it, or empty when it sent none, as MQTT 3.1.1 brokers never do.- Returns:
- the broker's explanation of its refusal for people diagnosing it, or empty when it sent none, as MQTT 3.1.1 brokers never do
-
serverReference
-