Skip to main content

Connecting MQTT

  1. In SourceFlow, drag an mqtt in node.
  2. Double-click the node, and then click next to Server.
ParameterDescription
NameOptional name for the MQTT broker configuration (for internal reference).
ServerThe hostname or IP address of the MQTT broker (e.g., localhost or broker.hivemq.com).
PortThe port used to connect to the MQTT broker (default is 1883 for non-TLS, 8883 for TLS).
Connect automaticallyIf enabled, Node-RED will try to connect to the broker automatically when the flow starts.
Use TLSEnable this option if the broker requires a secure TLS/SSL connection.
ProtocolThe MQTT protocol version to use for connection (e.g., MQTT v3.1.1 or v5.0).
Client IDOptional client ID. If blank, a unique one will be auto-generated. Must be unique per client.
Keep AliveThe maximum period (in seconds) between communications with the broker. Helps detect dropped connections.
Use clean sessionIf enabled, no persistent session is maintained with the broker; otherwise, session state (like subscriptions) is retained.
Username (Security tab)Username for authenticating with the MQTT broker, if required.
Password (Security tab)Password corresponding to the username for broker authentication. Stored securely.
  1. Click Add, and then enter the topic to be subscribed.
  2. Click Done.
  1. Connect a debug node at the end.
  2. Click Deploy at the upper-right corner, and then once the topic receives data, the flow will be triggered.