Skip to main content

MQTT Node

The gateway runs its own HiveMQ broker on the same machine (default port 1883, TLS 1884). This is the standard pattern for connecting to external SCADA or cloud IoT.

Box Broker Connection Info (2026.05+)
  • Broker URL: tcp://127.0.0.1:1883 (plain) / ssl://127.0.0.1:1884 (TLS)
  • Username / Password: app.properties's mqtt.server.user / mqtt.server.password — Mass-produced boxes have random credentials (verified in /etc/kopens/credentials.txt). The entrypoint automatically syncs HiveMQ auth.properties.
  • MQTT 5 Support (HiveMQ 2025.4): Full features for retained / will / session expiry / shared subscriptions.
  • Shared broker with Sparkplug B — Monitor by subscribing to spBv1.0/# simultaneously.

1. Node Types​

NodeUse Case
mqtt inSubscribe to topics — triggers the flow whenever a message arrives
mqtt outPublish messages

2. Broker (Server) Configuration — Shared across all nodes once created​

Double-click mqtt in or mqtt out node → Pencil icon on the right of the Server field → New broker configuration.

TabItemRecommended Value
ConnectionServer127.0.0.1 (Gateway's own HiveMQ) or external broker IP
Port1883 (or 8883 for TLS)
Client IDAuto-generated if left blank. Fixed ID recommended for production (e.g., edge-<gateway-id>-flow1)
Keep alive60 seconds recommended
Use TLSON for external cloud connections
SecurityUsername/PasswordUsed for broker authentication
MessagesLWT (Last Will)Topic edge/<id>/status + payload offline — Automatic notification if gateway fails suddenly
MessagesBirthRetain publish online to edge/<id>/status upon connection

3. Publishing (mqtt out) — Scenario: Sending all tag values to the cloud​

inject (1s) ──▶ 태그값 읽기 ──▶ change (topic 만들기) ──▶ mqtt out

change node:

ActionPropertyTo
Setmsg.topicplant/${msg.payload.tag_id}/value (J-Expression ${...} or mustache)
Setmsg.payload{ "ts": $millis(), "v": msg.payload.value, "q": msg.payload.value_read_status } (JSONata)

mqtt out node settings:

ItemValue
Topic(Leave blank → Use msg.topic)
QoS1 (Guaranteed delivery at least once) — 0 is acceptable for standard telemetry
Retainfalse (Real-time values) — true for state-based data

4. Subscribing (mqtt in) — Scenario: Writing to a tag via external command​

mqtt in (plant/+/cmd) ──▶ change (tag_id/value 추출) ──▶ 태그값 쓰기

mqtt in:

ItemValue
Topicplant/+/cmd (Wildcard + = single level)
QoS1
Outputparsed JSON object — Payload is automatically objectified

change:

ActionPropertyTo
Setmsg.tag_idmsg.topic.split('/')[1] (JSONata)
Movemsg.payload.value → msg.payload(Pass directly to write node)

With this setup, if an external SCADA publishes {"value":"1"} to the plant/TAG_VALVE_01/cmd topic, the gateway writes that value to the PLC.


5. Common Pitfalls​

SymptomCause / Solution
No messages receivedTopic wildcard (#/+) typo. Verify topic tree with separate tools like MQTT Explorer
Client frequently disconnectsClient ID conflict (another client connected with the same ID) — Assign unique IDs
Retain messages accumulating infinitelyRetain true publish on every message to the same topic. Use retain only for state-based data (online/offline, last alarm)
Incorrect message orderLimitation of QoS 0. Use QoS 1+ if order is critical

6. Next Steps​