MQTT proxy subscription

    Open , click the “Modules” tab on the left, and choose to add:

    image-20200927213049265

    Select MQTT broker subscription module

    Configure related parameters

    image-20200927213049265

    After clicking add, the module is added

    • NL (No Local)

      Whether application messages can be forwarded to the client that posted this message.

      -When the NL value is 0, it means that the application message can be forwarded to the client that published the message.

      -When the NL value is 1, it means that the application message cannot be forwarded to the client that published the message.

    • RH (Retain Handling)

      Whether to send a hold message when the subscription is established

      -0: Send a reserved message when the subscription is established

      -1: When the subscription is established, if the subscription does not currently exist, a reserved message will be sent

      -2: Do not send reserved messages when the subscription is established

    When configuring the topic subscribed by the agent, EMQX provides two placeholders and %u for users to use. EMQX will configure the %c and %u Replaced with the client'sClient IDand ʻUsername respectively. It should be noted that and %u must occupy an entire topic level.

    For example, after adding the rules in the above figure: configure two clients A and B, the Client ID of client A is testclientA, the Username is testerA, and the of client B is testclientB, ʻUsernameistesterB`.

    The client A uses the MQTT V3.1.1 protocol to connect to EMQX. According to the above configuration rules, the proxy subscription function will actively help the client subscribe to the two client/testclientA with QoS 1 and ʻuser/testerA` with QoS 2. For this topic, because the connection protocol is MQTT V3.1.1, No Local, Retain As Published, and Retain Handling in the configuration are not effective.