On this page
MQTT collection server
The MQTT Collection Server listens for MQTT clients and maps fields from valid JSON messages to gateway variables. RawString controls write publishing; it does not enable telemetry mapping from arbitrary non-JSON text.
Compatible devices and models
| Device series / model examples | Connection requirements |
|---|---|
| Devices or gateways reporting as MQTT clients | Devices connect to the gateway MQTT service with matching authentication, topics and payload mapping. Check the device MQTT version. |
Start the listener and connect a publisher
The MQTT collection server provides an MQTT broker listener on the gateway. Equipment or tools such as MQTTX connect to it and publish JSON. The gateway maps each message topic and JSONPath to variables. This plugin owns its listener; do not add an ordinary TCP or serial channel.
Gateway device and listener
- Open Development Configuration → Collection Configuration → Add Device, choose MQTT Collection Server, and name it
Collect_MQTT_Server. Choose a free port; two devices or brokers cannot bind the same endpoint.

- In Plugin Properties, select
Tcpand port18883. MQTTX on the same computer uses127.0.0.1:18883. Remote terminals use a reachable gateway interface IP with the listener allowed through the firewall. The Web management port is separate.

Enter 18883 in the listener port field on the right:

- Optionally set Allowed Client ID prefix to
collect-. Connecting clients then need IDs beginning with it. The example leaves credentials empty and SSL disabled; configure credentials or the server certificate to match the deployment. Save and enable the device.

MQTTX publisher
- Create
Collect_MQTTXin MQTTX: schememqtt://, host127.0.0.1, port18883, Client IDcollect-mqttx, MQTT3.1.1, Clean Session enabled. Match account and SSL/TLS settings to the gateway, then connect.

Open the complete MQTTX connection window. Across computers, change the MQTTX host to the gateway IP: 127.0.0.1 always refers to the computer running that program.
- Open Protocol Debug → Status Monitor on the gateway and locate
collect-mqttxin the client list. Its remote port is the client’s temporary source port, not the gateway listening port.

Plugin properties
Listener and authentication
| Setting | Description |
|---|---|
| Connection type | Default Tcp for native MQTT clients. Choose WebSocket for MQTT over WebSocket clients. Both ends must use the same transport. |
| Port | Default 1883. Local listening port, 18883 in the example. Use a free port reachable by the clients. |
| WebSocket path | Default /mqtt; used only for WebSocket. Clients use the same port and path, with wss:// when SSL is enabled. TCP does not use it. |
| Enable SSL | Disabled by default. Enables TLS on the listener. Clients must use SSL/TLS or WSS and trust the gateway certificate. |
| Server certificate | Select a server certificate with its private key from Certificate Management when SSL is enabled. The client connection host should match the certificate. |
| CA certificate | CA used to validate client certificates. Mutual TLS also requires the terminal’s client certificate and private key. |
| Allow untrusted certificate | Enabled by default. Disabling it also requires a valid client certificate. Configure the CA and terminal identity together. |
| SSL protocol | Default System Default negotiates through the operating system when SSL is enabled. Explicit versions require terminal and OS support. Legacy Default is the SSL 3.0/TLS 1.0 combination. |
| Check certificate revocation | Disabled by default. Enabling requires access to the relevant certificate status service. |
| Allowed Client ID prefix | Empty by default, imposing no prefix restriction. collect- accepts collect-mqttx but rejects sensor-1. This is a starting-string match, not a topic filter; + and # do not act as wildcards here. |
| Username | Empty by default. A non-empty value enables shared-account validation; clients must send the exact username and matching password. |
| Password | Empty by default. Validated with Username. Certificates, credentials, and the Client ID prefix are independent requirements when configured. |
Messages, diagnostics, and missing samples
| Setting | Description |
|---|---|
| QoS | Default 0, used for server publishes and RPC control messages. 0: at most once; 1: at least once; 2: exactly once. Broker and subscriber settings determine effective delivery. |
| Subscription publish concurrency | In versions exposing this option, default 1, range 1–2147483647. Limits concurrent sends per subscribing connection. Keep 1 for ordering; larger values may change arrival order. It does not control JSON collection processing concurrency. |
| Detailed log | Disabled by default. Enable for connection or message diagnosis; disable afterward to reduce logging. |
| Check and cleanup interval | Default 60000, in seconds. Readable variables become offline after this time without a sample and recover on a new valid message. Set the application’s permitted missing-sample duration; this is not disk cleanup. |
Create a variable and receive JSON
- Add
MQTT_Temperatureto the server device. ChooseInt16, Read only, and array length1for one integer. Use a floating-point type for decimals orObjectfor a complete object. Array length is not the number of topics; PLC word order and byte offsets do not apply.


- Open Variable Address → Edit fields. Enable Subscribe topic =
telemetry/line1and JSONPath =$.data.value. Leave explicit null, condition, publish, and RPC fields unchecked. Click Confirm and fill, then save.

The address is SubscribeTopic=telemetry/line1;Path=$.data.value;. Here the subscribe topic defines a collection filter; a publisher does not need to subscribe to that topic before reporting data.
- In the MQTTX send area, choose JSON, topic
telemetry/line1, QoS0, and Retain disabled. Enter the following payload and click the green arrow at the bottom right to send:
{"data":{"value":31}}

- Open Live Variables → Details. Compare current value
31, raw value, address, and collection time. Change the value and publish again to check continuing updates.

To publish from the gateway to subscribers, use Protocol Debug → Publish Message. Have a receiving client subscribe to telemetry/line1, enter that topic and {"data":{"value":32}}, select QoS 0, disable Retain, and publish. The receiving client should see 32. Outbound server publishing and inbound collection are separate directions; publishing does not insert the same message into the server’s own collection variable.

Write a variable and send commands to clients
Inbound JSON updates readable variables. Writing a command variable publishes a message to subscribers. Subscribe in MQTTX first, then use the variable’s Write action to check the actual topic, body, and direction.
- In connected MQTTX, click New Subscription, enter
commands/line1/#, choose QoS0, and confirm.

- Add
MQTT_Server_Commandunder the server device:Int16, Write only, array length1. Keep the existing temperature variable for inbound telemetry.


- In Edit fields, enable Publish topic =
commands/line1/server-setpoint, Payload mode =Json, and the Retain property with its switch off. Leave subscribe topic, JSONPath, response topic, and timeout unchecked. Click Confirm and fill.

The resulting address is:
PublishTopic=commands/line1/server-setpoint;PayloadMode=Json;Retain=false- Enable RPC write in the variable’s RPC Configuration and save. It permits variable writes; Response topic in the address controls waiting for an MQTT acknowledgement and is not needed for ordinary publishing. The switch is in the same location as in the client write steps.

- Click Write on
MQTT_Server_Commandin Live Variables. Enter43, check that it is recognized as a number, and submit.

- In MQTTX, find
commands/line1/server-setpointwith the JSON number43. The other message,commands/line1/setpointwith42, belongs to the separate client command example. Match each by its concrete topic. A server variable write sends to subscribing clients and does not automatically update the temperature variable.

The written value is the message body: 43 is not automatically wrapped in a data object. For {"setpoint":43}, use Object with Json and write that object. For unquoted RUN, use String with RawString and write RUN. See the client payload and acknowledgement steps for types, Retain, and {RequestId} responses. The server follows the same address rules and publishes through its listener to connected subscribers.
Address rule
Use PropertyName=Value; with properties in any order. Names are case-insensitive and unused properties can be omitted:
SubscribeTopic=vendor/device;Path=$.data.temperature;Condition=TelemetryCondition;ConditionParameters={"Minimum":"12.5"};The properties SubscribeTopic, Path, Condition, ConditionParameters, PublishTopic, PayloadMode, Retain, ResponseTopic, and Timeout follow the client address rules. The server listens on the gateway and can also provide the publishing client’s ID to the condition script.
Click Edit fields beside Variable Address, select a condition script, and fill in its named inputs. Click Confirm and fill, then save the variable. See condition parameter configuration for input types and escaping. Unspecified inputs use script defaults; Topic, MqttTopic, ClientId, and MqttClientId receive actual message context when not explicitly configured.
Existing eight-segment addresses remain supported. Applying changed fields in the editor generates the named format; existing addresses require no manual conversion.
Examples:
| Use | Address |
|---|---|
| Read a JSON value | SubscribeTopic=vendor/device;Path=$.data.temperature; |
| Condition with parameters | SubscribeTopic=vendor/device;Path=$.data.temperature;Condition=TelemetryCondition;ConditionParameters={"Minimum":"12.5"}; |
| Publish a raw write | PublishTopic=factory/a/reboot;PayloadMode=RawString;Retain=false; |
| RPC request and response | PublishTopic=factory/a/command/{RequestId};PayloadMode=Json;Retain=false;ResponseTopic=factory/a/response/{RequestId};Timeout=5000; |
Payload paths support $, dot paths such as items.0.value, filters [?()], wildcards [*] and .*, and recursive search $..name. With ||, the first existing candidate path is used. Exact case-sensitive property names are preferred; a unique case-insensitive match is used only when no exact name exists.
A present field with null does not guarantee fallback to the next path. Multiple matches select the first result rather than creating multiple variables. Create a read-only variable at SubscribeTopic=vendor/device;Path=$.data.temperature;, connect an independent client, and publish the following payload; the variable should receive 31 with a new collection time:
{"data":{"temperature":31}}The condition is a DataTrans script name. Its raw input contains the complete JSON payload; it may also declare Topic, MqttTopic, ClientId, or MqttClientId. A wildcard topic updates the same variable for every matching message, so filter by Topic or ClientId when values must be separated by source.
Publish topics cannot contain + or #; {RequestId} must be the final topic level.
A subscribe topic and JSONPath must be provided together; publish options require a publish topic. RPC response topic and timeout are a pair, and the timeout must be 100–60000 ms. A read-only variable cannot contain publish fields, a write-only variable cannot contain telemetry fields, and every variable must configure at least one route.
Device debug
Open Development Configuration → Collection Configuration, select the MQTT server device, open Protocol Debug at the top of the workspace.
MQTT server protocol panel
Use the panel to inspect clients, subscriptions, and server operations.
Functions
| Function | Purpose |
|---|---|
| Publish message | Publish a topic, payload, QoS, and Retain flag to subscribing clients. |
| Recent messages | Inspect the 10 most recently active topics and the last 10 received or published messages per topic. |
| Topic statistics | Inspect each topic and its current subscription count. |
| Client list | Inspect client ID, username, remote endpoint, and connection time. |
| Kick client | Disconnect a selected client; confirm that it is safe before using this action. |
Connection and messages
- Start the MQTT server and confirm its listening port.
- Connect a test MQTT client with an approved Client ID and credentials.
- Publish one JSON payload to an exact test topic.
- Confirm the condition, JSONPath, variable value, and collection time.
- Test a write only when the variable and server permissions allow it.
Keep the client connected but stop new telemetry to check the configured missing-sample interval. The variable should become offline and then recover after a new valid message; a connected client alone does not establish data freshness. Verify two clients separately when testing ClientId filtering, and confirm that rejected messages do not replace the accepted value or sample time.
For writes, Json preserves the input JSON type and RawString accepts only a string, publishing its unwrapped text. Enable the variable’s RPC write permission, inspect the message with a subscriber, and verify field feedback. RPC requires the matching RequestId and response within its timeout.
Recent messages
Open Recent messages in Protocol Debug, then expand a topic to read its payloads. Topics are ordered by their latest activity, and messages within a topic are newest first. Each message shows its recorded time, received or published direction, QoS, Retain flag, and payload encoding. Use Refresh to read the current records.

The current device instance retains up to 10 topics and 10 messages per topic. New messages and topics replace the oldest records. Stopping or reinitializing the device clears them. Client publications and server publications are recorded even without a variable mapping; a server publication is counted once regardless of subscriber count.
Each payload preview is limited to its first 64 KiB. Larger payloads show their full byte length and a truncation notice. Valid UTF-8 is displayed as text, ending at the last complete character if the limit splits a character. Invalid UTF-8 is displayed as Base64. Scroll the message list to browse the remaining records, or scroll a payload independently. With the list focused, Home and End reach its first and last messages. Records load when entering the tab or refreshing manually, without continuous payload polling. These runtime debug records do not replace historical storage or MQTT retained messages.
Troubleshooting
| Symptom | Check |
|---|---|
| Client cannot connect | Listener port, connection type, firewall, TLS certificate, credentials, allowed Client ID prefix, and client limit. |
| Message arrives but variable is unchanged | Exact topic, JSONPath, condition script, payload shape, and variable data type. |
| Values from different clients are mixed | Use exact topics or filter by ClientId in the condition script. |
| Publish operation fails | Client connection, topic permissions, QoS, retain setting, and server log. |
| Certificate is rejected | Server certificate, CA, client certificate trust, and TLS protocol. |
Related links
- Collection Configuration: Devices, variables, common permissions, and import.
- Certificate Management: Manage MQTT server, client, and CA certificates.
- Plugin Manual Index: Other collection and data-forwarding plugins.