Enum Class ReasonCode

java.lang.Object
java.lang.Enum<ReasonCode>
org.mqtt4j.hato.ReasonCode
All Implemented Interfaces:
Serializable, Comparable<ReasonCode>, Constable

public enum ReasonCode extends Enum<ReasonCode>

MQTT 5.0 reason codes shared by acknowledgements, disconnection, and authentication.

Each distinct wire value has one constant. In particular, SUCCESS represents 0x00: Success in acknowledgements and AUTH, Normal disconnection in DISCONNECT, and Granted QoS 0 in SUBACK. The packet determines which meaning applies.

A value defined here is not necessarily valid for every packet type. An MQTT 3.1.1 connection reports its return codes as the corresponding values here.

See MQTT 5.0, section 2.4, Table 2-6: Reason Codes.

  • Enum Constant Details

    • SUCCESS

      public static final ReasonCode SUCCESS
      Success, normal disconnection, or granted QoS 0, depending on the packet.
    • GRANTED_QOS_1

      public static final ReasonCode GRANTED_QOS_1
      The subscription is accepted with a maximum QoS of 1.
    • GRANTED_QOS_2

      public static final ReasonCode GRANTED_QOS_2
      The subscription is accepted with a maximum QoS of 2.
    • DISCONNECT_WITH_WILL_MESSAGE

      public static final ReasonCode DISCONNECT_WITH_WILL_MESSAGE
      The client requests disconnection and publication of its Will.
    • NO_MATCHING_SUBSCRIBERS

      public static final ReasonCode NO_MATCHING_SUBSCRIBERS
      The publication is accepted but has no matching subscribers.
    • NO_SUBSCRIPTION_EXISTED

      public static final ReasonCode NO_SUBSCRIPTION_EXISTED
      Unsubscription completed without finding a matching subscription.
    • CONTINUE_AUTHENTICATION

      public static final ReasonCode CONTINUE_AUTHENTICATION
      Authentication requires another exchange.
    • RE_AUTHENTICATE

      public static final ReasonCode RE_AUTHENTICATE
      The client starts authentication again on an existing connection.
    • UNSPECIFIED_ERROR

      public static final ReasonCode UNSPECIFIED_ERROR
      The operation failed without a more specific reason.
    • MALFORMED_PACKET

      public static final ReasonCode MALFORMED_PACKET
      The packet cannot be parsed according to the protocol's format.
    • PROTOCOL_ERROR

      public static final ReasonCode PROTOCOL_ERROR
      The packet violates a protocol rule or the expected exchange sequence.
    • IMPLEMENTATION_SPECIFIC_ERROR

      public static final ReasonCode IMPLEMENTATION_SPECIFIC_ERROR
      The implementation declines an otherwise valid packet.
    • UNSUPPORTED_PROTOCOL_VERSION

      public static final ReasonCode UNSUPPORTED_PROTOCOL_VERSION
      The server does not support the requested MQTT version.
    • CLIENT_IDENTIFIER_NOT_VALID

      public static final ReasonCode CLIENT_IDENTIFIER_NOT_VALID
      The server rejects the client identifier.
    • BAD_USER_NAME_OR_PASSWORD

      public static final ReasonCode BAD_USER_NAME_OR_PASSWORD
      The server rejects the supplied user name or password.
    • NOT_AUTHORIZED

      public static final ReasonCode NOT_AUTHORIZED
      The operation is not permitted for this client.
    • SERVER_UNAVAILABLE

      public static final ReasonCode SERVER_UNAVAILABLE
      The server cannot currently accept a connection.
    • SERVER_BUSY

      public static final ReasonCode SERVER_BUSY
      The server cannot currently accept work because it is busy.
    • BANNED

      public static final ReasonCode BANNED
      The server has banned the client.
    • SERVER_SHUTTING_DOWN

      public static final ReasonCode SERVER_SHUTTING_DOWN
      The server is closing the connection as part of its shutdown.
    • BAD_AUTHENTICATION_METHOD

      public static final ReasonCode BAD_AUTHENTICATION_METHOD
      The authentication method is unsupported or inconsistent with the exchange.
    • KEEP_ALIVE_TIMEOUT

      public static final ReasonCode KEEP_ALIVE_TIMEOUT
      The server received no packet within the permitted keep-alive interval.
    • SESSION_TAKEN_OVER

      public static final ReasonCode SESSION_TAKEN_OVER
      Another connection using the same client identifier has replaced this connection.
    • TOPIC_FILTER_INVALID

      public static final ReasonCode TOPIC_FILTER_INVALID
      The receiver does not accept the topic filter.
    • TOPIC_NAME_INVALID

      public static final ReasonCode TOPIC_NAME_INVALID
      The receiver does not accept the topic name.
    • PACKET_IDENTIFIER_IN_USE

      public static final ReasonCode PACKET_IDENTIFIER_IN_USE
      The packet identifier is already assigned to an unfinished exchange.
    • PACKET_IDENTIFIER_NOT_FOUND

      public static final ReasonCode PACKET_IDENTIFIER_NOT_FOUND
      The receiver has no exchange for the packet identifier.
    • RECEIVE_MAXIMUM_EXCEEDED

      public static final ReasonCode RECEIVE_MAXIMUM_EXCEEDED
      Too many QoS 1 or 2 publications are awaiting acknowledgement.
    • TOPIC_ALIAS_INVALID

      public static final ReasonCode TOPIC_ALIAS_INVALID
      The topic alias is zero or exceeds the negotiated maximum.
    • PACKET_TOO_LARGE

      public static final ReasonCode PACKET_TOO_LARGE
      The packet exceeds the receiver's permitted size.
    • MESSAGE_RATE_TOO_HIGH

      public static final ReasonCode MESSAGE_RATE_TOO_HIGH
      The publication rate exceeds the receiver's capacity or policy.
    • QUOTA_EXCEEDED

      public static final ReasonCode QUOTA_EXCEEDED
      A resource or administrative quota has been exhausted.
    • ADMINISTRATIVE_ACTION

      public static final ReasonCode ADMINISTRATIVE_ACTION
      An administrative decision causes disconnection.
    • PAYLOAD_FORMAT_INVALID

      public static final ReasonCode PAYLOAD_FORMAT_INVALID
      The payload does not conform to its declared format.
    • RETAIN_NOT_SUPPORTED

      public static final ReasonCode RETAIN_NOT_SUPPORTED
      The server does not support retained publications.
    • QOS_NOT_SUPPORTED

      public static final ReasonCode QOS_NOT_SUPPORTED
      The requested QoS exceeds what the server supports.
    • USE_ANOTHER_SERVER

      public static final ReasonCode USE_ANOTHER_SERVER
      The client should try a different server.
    • SERVER_MOVED

      public static final ReasonCode SERVER_MOVED
      The server has moved to a different address.
    • SHARED_SUBSCRIPTIONS_NOT_SUPPORTED

      public static final ReasonCode SHARED_SUBSCRIPTIONS_NOT_SUPPORTED
      The server does not support shared subscriptions.
    • CONNECTION_RATE_EXCEEDED

      public static final ReasonCode CONNECTION_RATE_EXCEEDED
      The rate of new connections exceeds the server's limit.
    • MAXIMUM_CONNECT_TIME

      public static final ReasonCode MAXIMUM_CONNECT_TIME
      The connection has reached the server's permitted lifetime.
    • SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED

      public static final ReasonCode SUBSCRIPTION_IDENTIFIERS_NOT_SUPPORTED
      The server does not support subscription identifiers.
    • WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED

      public static final ReasonCode WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED
      The server does not support wildcard subscriptions.
  • Method Details

    • values

      public static ReasonCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ReasonCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • value

      public int value()
      Returns the unsigned byte value used by MQTT 5.0 on the wire.
      Returns:
      the unsigned byte value used by MQTT 5.0 on the wire
    • of

      public static ReasonCode of(int value)

      Resolves an unsigned MQTT 5.0 wire value to its reason code.

      Zero always resolves to SUCCESS, including for DISCONNECT and SUBACK. The caller must separately check whether the code is permitted for the packet being decoded.

      Parameters:
      value - the unsigned byte value, represented as an int
      Returns:
      the reason code for that value
      
      Throws:
      IllegalArgumentException -
      if `value` is outside 0 to 255 or is undefined