org.eclipse.paho.client.mqttv3
Class MqttException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byorg.eclipse.paho.client.mqttv3.MqttException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MqttPersistenceException, MqttSecurityException

public class MqttException
extends java.lang.Exception

Thrown if an error occurs communicating with the server.

See Also:
Serialized Form

Field Summary
static short REASON_CODE_BROKER_UNAVAILABLE
          The broker was not available to handle the request.
static short REASON_CODE_CLIENT_ALREADY_CONNECTED
          The client is already connected.
static short REASON_CODE_CLIENT_ALREADY_DISCONNECTED
          The client is already disconnected.
static short REASON_CODE_CLIENT_DISCONNECT_PROHIBITED
          Thrown when an attempt to call MqttClient.disconnect() has been made from within a method on MqttCallback.
static short REASON_CODE_CLIENT_DISCONNECTING
          The client is currently disconnecting and cannot accept any new work.
static short REASON_CODE_CLIENT_EXCEPTION
          Client encountered an exception.
static short REASON_CODE_CLIENT_NOT_CONNECTED
          The client is not connected to the server.
static short REASON_CODE_CLIENT_TIMEOUT
          Client timed out while waiting for a response from the server.
static short REASON_CODE_CONNECTION_LOST
          The client has been unexpectedly disconnected from the server.
static short REASON_CODE_FAILED_AUTHENTICATION
          Authentication with the server has failed, due to a bad user name or password.
static short REASON_CODE_INVALID_CLIENT_ID
          The server has rejected the supplied client ID
static short REASON_CODE_INVALID_MESSAGE
          Protocol error: the message was not recognized as a valid MQTT packet.
static short REASON_CODE_INVALID_PROTOCOL_VERSION
          The protocol version requested is not supported by the server.
static short REASON_CODE_NO_MESSAGE_IDS_AVAILABLE
          Internal error, caused by no new message IDs being available.
static short REASON_CODE_NOT_AUTHORIZED
          Not authorized to perform the requested operation
static short REASON_CODE_SERVER_CONNECT_ERROR
          Unable to connect to server
static short REASON_CODE_SOCKET_FACTORY_MISMATCH
          Server URI and supplied SocketFactory do not match.
static short REASON_CODE_SSL_CONFIG_ERROR
          SSL configuration error.
static short REASON_CODE_UNEXPECTED_ERROR
          An unexpected error has occurred.
 
Constructor Summary
MqttException(int reasonCode)
          Constructs a new MqttException with the specified code as the underlying reason.
MqttException(int reason, java.lang.Throwable cause)
          Constructs a new MqttException with the specified Throwable as the underlying reason.
MqttException(java.lang.Throwable cause)
          Constructs a new MqttException with the specified Throwable as the underlying reason.
 
Method Summary
 java.lang.Throwable getCause()
          Returns the underlying cause of this exception, if available.
 java.lang.String getMessage()
          Returns the detail message for this exception.
 int getReasonCode()
          Returns the reason code for this exception.
 java.lang.String toString()
          Returns a String representation of this exception.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REASON_CODE_CLIENT_EXCEPTION

public static final short REASON_CODE_CLIENT_EXCEPTION
Client encountered an exception. Use the getCause() method to get the underlying reason.

See Also:
Constant Field Values

REASON_CODE_INVALID_PROTOCOL_VERSION

public static final short REASON_CODE_INVALID_PROTOCOL_VERSION
The protocol version requested is not supported by the server.

See Also:
Constant Field Values

REASON_CODE_INVALID_CLIENT_ID

public static final short REASON_CODE_INVALID_CLIENT_ID
The server has rejected the supplied client ID

See Also:
Constant Field Values

REASON_CODE_BROKER_UNAVAILABLE

public static final short REASON_CODE_BROKER_UNAVAILABLE
The broker was not available to handle the request.

See Also:
Constant Field Values

REASON_CODE_FAILED_AUTHENTICATION

public static final short REASON_CODE_FAILED_AUTHENTICATION
Authentication with the server has failed, due to a bad user name or password.

See Also:
Constant Field Values

REASON_CODE_NOT_AUTHORIZED

public static final short REASON_CODE_NOT_AUTHORIZED
Not authorized to perform the requested operation

See Also:
Constant Field Values

REASON_CODE_UNEXPECTED_ERROR

public static final short REASON_CODE_UNEXPECTED_ERROR
An unexpected error has occurred.

See Also:
Constant Field Values

REASON_CODE_CLIENT_TIMEOUT

public static final short 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_NO_MESSAGE_IDS_AVAILABLE

public static final short REASON_CODE_NO_MESSAGE_IDS_AVAILABLE
Internal error, caused by no new message IDs being available.

See Also:
Constant Field Values

REASON_CODE_CLIENT_ALREADY_CONNECTED

public static final short REASON_CODE_CLIENT_ALREADY_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_CLIENT_DISCONNECTING

public static final short REASON_CODE_CLIENT_DISCONNECTING
The client is currently disconnecting and cannot accept any new work. This can occur when waiting on a token, and then disconnecting the client. If the message delivery does not complete within the quiesce timeout period, then the waiting token will be notified with an exception.

See Also:
Constant Field Values

REASON_CODE_SERVER_CONNECT_ERROR

public static final short REASON_CODE_SERVER_CONNECT_ERROR
Unable to connect to server

See Also:
Constant Field Values

REASON_CODE_CLIENT_NOT_CONNECTED

public static final short REASON_CODE_CLIENT_NOT_CONNECTED
The client is not connected to the server. The MqttClient.connect() or MqttClient.connect(MqttConnectOptions) method must be called first. It is also possible that the connection was lost - see MqttClient.setCallback(MqttCallback) for a way to track lost connections.

See Also:
Constant Field Values

REASON_CODE_SOCKET_FACTORY_MISMATCH

public static final short REASON_CODE_SOCKET_FACTORY_MISMATCH
Server URI and supplied SocketFactory do not match. URIs beginning tcp:// must use a javax.net.SocketFactory, and URIs beginning ssl:// must use a javax.net.ssl.SSLSocketFactory.

See Also:
Constant Field Values

REASON_CODE_SSL_CONFIG_ERROR

public static final short REASON_CODE_SSL_CONFIG_ERROR
SSL configuration error.

See Also:
Constant Field Values

REASON_CODE_CLIENT_DISCONNECT_PROHIBITED

public static final short REASON_CODE_CLIENT_DISCONNECT_PROHIBITED
Thrown when an attempt to call MqttClient.disconnect() has been made from within a method on MqttCallback. These methods are invoked by the client's thread, and must not be used to control disconnection.

See Also:
MqttCallback.messageArrived(MqttTopic, MqttMessage), Constant Field Values

REASON_CODE_INVALID_MESSAGE

public static final short 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 short REASON_CODE_CONNECTION_LOST
The client has been unexpectedly disconnected from the server. The cause will provide more details.

See Also:
Constant Field Values
Constructor Detail

MqttException

public MqttException(int reasonCode)
Constructs a new MqttException with the specified code as the underlying reason.

Parameters:
reasonCode - the reason code for the exception.

MqttException

public MqttException(java.lang.Throwable cause)
Constructs a new MqttException with the specified Throwable as the underlying reason.

Parameters:
cause - the underlying cause of the exception.

MqttException

public MqttException(int reason,
                     java.lang.Throwable cause)
Constructs a new MqttException with the specified Throwable as 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.

getCause

public java.lang.Throwable getCause()
Returns the underlying cause of this exception, if available.

Returns:
the Throwable that was the root cause of this exception, which may be null.

getMessage

public java.lang.String getMessage()
Returns the detail message for this exception.

Returns:
the detail message, which may be null.

toString

public java.lang.String toString()
Returns a String representation of this exception.

Returns:
a String representation of this exception.