org.eclipse.paho.client.mqttv3
Class MqttException

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

public class MqttException
extends 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_DISCONNECTED
          The client is already disconnected.
static short REASON_CODE_CLIENT_CLOSED
          The client is closed - no operations are permitted on the client in this state.
static short REASON_CODE_CLIENT_CONNECTED
          The client is already connected.
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_CONNECT_IN_PROGRESS
          A connect operation in already in progress, only one connect can happen at a time.
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_MAX_INFLIGHT
          A request has been made to send a message but the maximum number of inflight messages has already been reached.
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_TOKEN_INUSE
          A request has been made to use a token that is already associated with another action.
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, Throwable cause)
          Constructs a new MqttException with the specified Throwable as the underlying reason.
MqttException(Throwable cause)
          Constructs a new MqttException with the specified Throwable as the underlying reason.
 
Method Summary
 Throwable getCause()
          Returns the underlying cause of this exception, if available.
 String getMessage()
          Returns the detail message for this exception.
 int getReasonCode()
          Returns the reason code for this exception.
 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
clone, equals, finalize, 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_CONNECTED

public static final short 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_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(String, 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

REASON_CODE_CONNECT_IN_PROGRESS

public static final short REASON_CODE_CONNECT_IN_PROGRESS
A connect operation in already in progress, only one connect can happen at a time.

See Also:
Constant Field Values

REASON_CODE_CLIENT_CLOSED

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

public static final short REASON_CODE_TOKEN_INUSE
A request has been made to use a token that is already associated with another action. If the action is complete the reset() can ve called on the token to allow it to be reused.

See Also:
Constant Field Values

REASON_CODE_MAX_INFLIGHT

public static final short REASON_CODE_MAX_INFLIGHT
A request has been made to send a message but the maximum number of inflight messages has already been reached. Once one or more messages have been moved then new messages can be sent.

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(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,
                     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 Throwable getCause()
Returns the underlying cause of this exception, if available.

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

getMessage

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

Overrides:
getMessage in class Throwable
Returns:
the detail message, which may be null.

toString

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

Overrides:
toString in class Throwable
Returns:
a String representation of this exception.


Copyright © 2013. All Rights Reserved.