Class MqttBrokerDisconnectException

All Implemented Interfaces:
Serializable

public final class MqttBrokerDisconnectException extends MqttException
An MQTT 5.0 broker ended the connection with DISCONNECT. This is the cause in the Disconnection of that connection, and pending operations fail with MqttConnectionLostException that carries it as its cause. The reason code decides whether the client reconnects; see ReconnectPolicy. With ReasonCode.USE_ANOTHER_SERVER or ReasonCode.SERVER_MOVED, the broker can name another server in serverReference(). The client does not follow it; an application that does creates a client for that server. MQTT 3.1.1 brokers close connections without DISCONNECT, so this exception appears only with MQTT 5.0.
See Also:
  • Constructor Details

    • MqttBrokerDisconnectException

      public MqttBrokerDisconnectException(ReasonCode reasonCode, @Nullable String reasonString, @Nullable String serverReference)
      A DISCONNECT from the broker, with the explanation and the server reference that it carried, if any.
      Parameters:
      reasonCode - the reason code of the broker's DISCONNECT
      reasonString - the broker's explanation, or null when it sent none
      serverReference - the server that the broker named, or null when it named none
  • Method Details

    • reasonCode

      public ReasonCode reasonCode()
      Returns the reason code of the broker's DISCONNECT.
      Returns:
      the reason code of the broker's DISCONNECT
    • reasonString

      public Optional<String> reasonString()
      Returns the broker's explanation for people diagnosing the end, or empty when it sent none.
      Returns:
      the broker's explanation for people diagnosing the end, or empty when it sent none
    • serverReference

      public Optional<String> serverReference()
      Returns the server that the broker named for the client to use instead, or empty when it named none.
      Returns:
      the server that the broker named for the client to use instead, or empty when it named none