Class MqttProtocolException
- All Implemented Interfaces:
Serializable
A locally detected failure to process an incoming MQTT packet.
The reason distinguishes malformed input, protocol rule violations, receive size limits, and
more unacknowledged MQTT 5.0 QoS 1 and QoS 2 publications than the client's Receive Maximum
(ReasonCode.RECEIVE_MAXIMUM_EXCEEDED). ReasonCode.PACKET_TOO_LARGE can indicate a local
limit rather than a peer protocol violation.
Reported as Disconnection.cause() or as the cause of MqttConnectException or
MqttConnectionLostException. Before such a failure closes an established MQTT 5.0
connection, the client sends the broker DISCONNECT with this reason code, which does not stop
the broker from publishing the Will. A QoS 2 publication that the broker acknowledges with
PUBACK fails with this exception directly, without ending the connection; see
MqttPublisher.publish(MqttMessage). A SUBACK that violates the protocol also ends its
subscription with this exception; see Subscription.established(). An underlying cause is
retained for diagnostics; applications should use this exception and reasonCode() to
classify the failure.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMqttProtocolException(String message, ReasonCode reasonCode) A failure without an underlying cause.MqttProtocolException(String message, ReasonCode reasonCode, Throwable cause) A failure with an underlying cause, which is retained for diagnostics. -
Method Summary
Modifier and TypeMethodDescriptionReturns the local failure classification, including for MQTT 3.1.1 connections.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MqttProtocolException
A failure without an underlying cause.- Parameters:
message- the detail messagereasonCode- the local failure classification- Throws:
IllegalArgumentException-if the reason is not [MALFORMED_PACKET][ReasonCode#MALFORMED_PACKET], [PROTOCOL_ERROR][ReasonCode#PROTOCOL_ERROR], [PACKET_TOO_LARGE][ReasonCode#PACKET_TOO_LARGE], [TOPIC_ALIAS_INVALID][ReasonCode#TOPIC_ALIAS_INVALID], or [RECEIVE_MAXIMUM_EXCEEDED][ReasonCode#RECEIVE_MAXIMUM_EXCEEDED]
-
MqttProtocolException
A failure with an underlying cause, which is retained for diagnostics.- Parameters:
message- the detail messagereasonCode- the local failure classificationcause- the underlying cause- Throws:
IllegalArgumentException-if the reason is not [MALFORMED_PACKET][ReasonCode#MALFORMED_PACKET], [PROTOCOL_ERROR][ReasonCode#PROTOCOL_ERROR], [PACKET_TOO_LARGE][ReasonCode#PACKET_TOO_LARGE], [TOPIC_ALIAS_INVALID][ReasonCode#TOPIC_ALIAS_INVALID], or [RECEIVE_MAXIMUM_EXCEEDED][ReasonCode#RECEIVE_MAXIMUM_EXCEEDED]
-
-
Method Details
-
reasonCode
Returns the local failure classification, including for MQTT 3.1.1 connections. This is not a reason code received from the broker.- Returns:
- the local failure classification, including for MQTT 3.1.1 connections
-