Interface ModifiableConnackPacket

    • Method Detail

      • setReasonString

        void setReasonString​(@Nullable String reasonString)
        Set the reason string.

        A reason must not be set for a successful connack.

        This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.

        Parameters:
        reasonString - The reason string to set.
        Throws:
        IllegalStateException - If reason code is ConnackReasonCode.SUCCESS.
        IllegalArgumentException - If the reason string is not a valid UTF-8 string.
        IllegalArgumentException - If the reason string exceeds the UTF-8 string length limit.
        Since:
        4.2.0, CE 2020.1
      • setResponseInformation

        void setResponseInformation​(@Nullable String responseInformation)
        Set the response information.

        This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.

        Parameters:
        responseInformation - The new response information for the CONNACK.
        Throws:
        IllegalArgumentException - If the response information is not a valid UTF-8 string.
        IllegalArgumentException - If the response information exceeds the UTF-8 string length limit.
        IllegalStateException - If the response information was not requested in the connect packet.
        Since:
        4.2.0, CE 2020.1
      • setServerReference

        void setServerReference​(@Nullable String serverReference)
        Set the server reference.

        This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.

        Parameters:
        serverReference - The new server reference for the CONNACK.
        Throws:
        IllegalArgumentException - If the server reference is not a valid UTF-8 string.
        IllegalArgumentException - If the server reference exceeds the UTF-8 string length limit.
        Since:
        4.2.0, CE 2020.1
      • setAssignedClientIdentifier

        void setAssignedClientIdentifier​(@Nullable String assignedClientIdentifier)
        Set the assigned client identifier that is sent in the CONNACK packet.

        This does not change the client identifier for HiveMQ, only the content of the CONNACK packet that is sent to the client is changed.

        If you want to change the client identifier used by HiveMQ use a ConnectInboundInterceptor instead.

        Set this value to null to prevent a assigned identifier from being sent to the client in the CONNACK packet.

        This setting is only respected for MQTT 5 clients. For MQTT 3.x clients this setting is ignored.

        Parameters:
        assignedClientIdentifier - The assigned client identifier sent in the CONNACK.
        Throws:
        IllegalArgumentException - If the client identifier is not a valid UTF-8 string.
        IllegalArgumentException - If the client identifier exceeds the UTF-8 string length limit.
        IllegalArgumentException - If the client identifier is empty. Use null to prevent sending the assigned identifier
        Since:
        4.6.0, CE 2021.1
      • setSessionPresent

        void setSessionPresent​(boolean sessionPresent)
        Sets the session present flag in the CONNACK packet HiveMQ sends to the client.

        This flag only impacts the content of the CONNACK packet, the flag does not change overall HiveMQ client session behavior.

        CAUTION: Clients typically clear their previous state when they receive a CONNACK packet with sessionPresent = false. Setting this flag to false can impact pending QoS 2 message flows.

        Parameters:
        sessionPresent - The session present flag sent in the CONNACK.
        Since:
        4.28.0, CE 2024.4