Package org.eclipse.paho.client.mqttv3
Class MqttException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.eclipse.paho.client.mqttv3.MqttException
-
- All Implemented Interfaces:
Serializable
public class MqttException extends RuntimeException
Thrown if an error occurs communicating with the server.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static shortREASON_CODE_CLIENT_ALREADY_DISCONNECTEDThe client is already disconnected.static intREASON_CODE_CLIENT_CLOSEDThe client is closed - no operations are permitted on the client in this state.static intREASON_CODE_CLIENT_CONNECTEDThe client is already connected.static intREASON_CODE_CLIENT_EXCEPTIONClient encountered an exception.static intREASON_CODE_CLIENT_NOT_CONNECTEDThe client is not connected to the server.static intREASON_CODE_CLIENT_TIMEOUTClient timed out while waiting for a response from the server.static intREASON_CODE_CONNECTION_LOSTThe client has been unexpectedly disconnected from the server.static intREASON_CODE_INVALID_MESSAGEProtocol error: the message was not recognized as a valid MQTT packet.static intREASON_CODE_SERVER_CONNECT_ERRORUnable to connect to server.static intREASON_CODE_SERVER_EXPECTED_CLEAN_SESSIONServer inconsistency (clean session not accepted).static intREASON_CODE_SERVER_MESSAGE_LENGTH_OVERFLOWServer inconsistency (message length integer overflow).static intREASON_CODE_SERVER_UNEXPECTED_ACK_MESSAGEServer inconsistency (received message acknowledgment to unexpected action).static intREASON_CODE_SERVER_UNEXPECTED_ACK_PACKET_IDENTIFIERServer inconsistency (received message acknowledgment to unexpected packet identifier).static intREASON_CODE_SERVER_UNEXPECTED_PINGRESP_MESSAGEServer inconsistency (received unexpected ping response packet).static intREASON_CODE_SUBSCRIBE_FAILEDError from subscribe - returned from the server.
-
Constructor Summary
Constructors Constructor Description MqttException(int reasonCode)Constructs a newMqttExceptionwith the specified code as the underlying reason.MqttException(int reason, Throwable cause)Constructs a newMqttExceptionwith the specifiedThrowableas the underlying reason.MqttException(Throwable cause)Constructs a newMqttExceptionwith the specifiedThrowableas the underlying reason.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetMessage()Returns the detail message for this exception.intgetReasonCode()Returns the reason code for this exception.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, toString
-
-
-
-
Field Detail
-
REASON_CODE_CLIENT_EXCEPTION
public static final int REASON_CODE_CLIENT_EXCEPTION
Client encountered an exception. Use theThrowable.getCause()method to get the underlying reason.- See Also:
- Constant Field Values
-
REASON_CODE_SUBSCRIBE_FAILED
public static final int REASON_CODE_SUBSCRIBE_FAILED
Error from subscribe - returned from the server.- See Also:
- Constant Field Values
-
REASON_CODE_CLIENT_TIMEOUT
public static final int REASON_CODE_CLIENT_TIMEOUT
Client timed out while waiting for a response from the server. The server is no longer responding to keep-alive messages.- See Also:
- Constant Field Values
-
REASON_CODE_CLIENT_CONNECTED
public static final int REASON_CODE_CLIENT_CONNECTED
The client is already connected.- See Also:
- Constant Field Values
-
REASON_CODE_CLIENT_ALREADY_DISCONNECTED
public static final short REASON_CODE_CLIENT_ALREADY_DISCONNECTED
The client is already disconnected.- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_CONNECT_ERROR
public static final int REASON_CODE_SERVER_CONNECT_ERROR
Unable to connect to server.- See Also:
- Constant Field Values
-
REASON_CODE_CLIENT_NOT_CONNECTED
public static final int REASON_CODE_CLIENT_NOT_CONNECTED
The client is not connected to the server. TheMqttClient.connect()orMqttClient.connect(MqttConnectOptions)method must be called first. It is also possible that the connection was lost - seeMqttClient.setCallback(MqttCallback)for a way to track lost connections.- See Also:
- Constant Field Values
-
REASON_CODE_INVALID_MESSAGE
public static final int REASON_CODE_INVALID_MESSAGE
Protocol error: the message was not recognized as a valid MQTT packet. Possible reasons for this include connecting to a non-MQTT server, or connecting to an SSL server port when the client isn't using SSL.- See Also:
- Constant Field Values
-
REASON_CODE_CONNECTION_LOST
public static final int REASON_CODE_CONNECTION_LOST
The client has been unexpectedly disconnected from the server. Thecausewill provide more details.- See Also:
- Constant Field Values
-
REASON_CODE_CLIENT_CLOSED
public static final int REASON_CODE_CLIENT_CLOSED
The client is closed - no operations are permitted on the client in this state. New up a new client to continue.- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_MESSAGE_LENGTH_OVERFLOW
public static final int REASON_CODE_SERVER_MESSAGE_LENGTH_OVERFLOW
Server inconsistency (message length integer overflow).- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_EXPECTED_CLEAN_SESSION
public static final int REASON_CODE_SERVER_EXPECTED_CLEAN_SESSION
Server inconsistency (clean session not accepted).- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_UNEXPECTED_ACK_MESSAGE
public static final int REASON_CODE_SERVER_UNEXPECTED_ACK_MESSAGE
Server inconsistency (received message acknowledgment to unexpected action).- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_UNEXPECTED_ACK_PACKET_IDENTIFIER
public static final int REASON_CODE_SERVER_UNEXPECTED_ACK_PACKET_IDENTIFIER
Server inconsistency (received message acknowledgment to unexpected packet identifier).- See Also:
- Constant Field Values
-
REASON_CODE_SERVER_UNEXPECTED_PINGRESP_MESSAGE
public static final int REASON_CODE_SERVER_UNEXPECTED_PINGRESP_MESSAGE
Server inconsistency (received unexpected ping response packet).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MqttException
public MqttException(int reasonCode)
Constructs a newMqttExceptionwith the specified code as the underlying reason.- Parameters:
reasonCode- the reason code for the exception.
-
MqttException
public MqttException(Throwable cause)
Constructs a newMqttExceptionwith the specifiedThrowableas the underlying reason.- Parameters:
cause- the underlying cause of the exception.
-
MqttException
public MqttException(int reason, Throwable cause)Constructs a newMqttExceptionwith the specifiedThrowableas the underlying reason.- Parameters:
reason- the reason code for the exception.cause- the underlying cause of the exception.
-
-
Method Detail
-
getReasonCode
public int getReasonCode()
Returns the reason code for this exception.- Returns:
- the code representing the reason for this exception.
-
getMessage
@NonNull public String getMessage()
Returns the detail message for this exception.- Overrides:
getMessagein classThrowable- Returns:
- the detail message, which may be
null.
-
-