Skip to Content
On this page

Gateway MQTT collection client

This plugin is used on a central Gateway to collect variables from multiple edge Gateways through one shared MQTT broker connection.

It is not a general MQTT JSON collector. It accepts the current TGateway Gateway MQTT protocol and uses RemoteKey to separate each edge Gateway’s variables, devices, online state, snapshots, and remote writes.

Compatible devices and models

Device series / model examplesConnection requirements
TGateway gateway data publishersConnect to the publisher MQTT service using TGateway topics and message structure. Use MQTT collection plugins for generic device JSON messages.

Synchronize one edge variable to the center

This example uses source edge-01 and the edge device Collect_OPC_UA variable Ramp1: Int32, read-only and continuously changing. Its remote directory ID is 877079827984453. Copy the actual ID from your own remote directory.

  1. Confirm the edge variable has a current value. Create the forwarding group below, add Ramp1, and enable both the group and its MQTT client forwarding target.
  2. Add this collector under No channel at the center. Both sides connect to the same Broker. Here the endpoint is 127.0.0.1:18886, with distinct Client IDs collect-central-01 and collect-edge-01-uplink. On separate computers, replace loopback with the reachable Broker address.
  3. Add enabled source edge-01, save and enable the collector. Select the source in Protocol debug → Remote gateways and request a snapshot. Open Remote variables and compare the device, Ramp1, Int32 and ReadOnly fields.

Remote directory showing source variable ID, device, Ramp1, Int32 and ReadOnly

  1. Use Synchronize current remote for the source. Review additions, updates and conflicts under Variable synchronization. This plan adds one variable with zero conflicts. Check the source and plan, then click Confirm and apply before the confirmation deadline; preview again if it expires.

Synchronization preview with one addition and Confirm and apply

  1. Open the new mirror in Realtime variables. Its address is edge-01/877079827984453; Int32 and ReadOnly match the directory. The local ID 877119118921797 is different and must not replace the remote ID. Watch the value and collection time update with the source; the instantaneous number in the image is not a fixed expected value.

Center mirror showing its complete source address, type, access and current value

Mirror settingBehavior
AddressRemoteKey/RemoteVariableId; a display name, Topic or PLC register is not a substitute.
Data typeAutomatic synchronization uses the remote declaration. Use Object only for a source object, not for every remote point.
AccessNew mirrors default to read-only. Remote writing also requires the center switch, edge RPC and source-variable permissions.
NamesReview naming/address conflicts. Renaming a source preserves its ID; deleting and recreating it can produce a different ID.
Type changesRefresh the directory and preview synchronization; inspect dependent expressions, alarms and forwarding configurations. Numeric 32 and string "32" have different meanings.
TimestampsValues carry edge collection time. Synchronize clocks. Snapshot interval controls full-state refresh, while edge group settings control realtime publication.

Snapshot, request and offline intervals are in seconds. 60/30/180 means a snapshot every 60 seconds, a 30-second request deadline and offline detection after 180 seconds without a valid source message. Offline timeout must exceed snapshot interval.

Choose the mode and data path

Choose a Mode

ModeUse WhenCentral GatewayEdge Gateways
Gateway MQTT collection clientA shared Broker already exists, or every Gateway can only make outbound connectionsUses one persistent ClientId and subscribes to all configured sourcesMultiple MQTT Client Forwarding targets connect to the same Broker and publish under their own RemoteKey
Gateway MQTT collection serverThe central Gateway can expose an inbound MQTT portListens on one port and binds each edge session to a ClientId, credentials, and optional certificate fingerprintMultiple MQTT Client Forwarding targets connect directly to the central Gateway

Prepare the Deployment

  1. Assign every edge Gateway a stable RemoteKey containing only ASCII letters, digits, hyphens, or underscores.
  2. Use the same Topic root on the collector and all edge producers. The default is TGateway/Gateway.
  3. Create a MQTT Client Forwarding target on the Data Forwarding page of every edge Gateway, keep Retain disabled, and configure the variable, data-request, and RPC Topics as described below.
  4. For remote writes, enable permissions on the edge producer, the central collector, and the target variable.
  5. Enable TLS according to the network policy. In Server mode, configure unique credentials for every source. If certificate fingerprints are enabled, bind a different certificate to each source.

Complete Data Path

Gateway MQTT collection client and Gateway MQTT collection server run only on the central Gateway and perform inbound collection. MQTT upload from each edge Gateway continues to use the existing MQTT Client Forwarding data-forwarding plugin. No second Gateway-specific producer plugin is required.

Collected variables on an edge Gateway → Data-forwarding group (selects scope and trigger mode) → MqttClientProducer (uploads values and handles snapshot/write requests) → Shared Broker or the central Gateway MQTT listener → GatewayMqttCollectClient / GatewayMqttCollectServer → Mirror variables on the central Gateway

Client and Server in the plugin names describe the MQTT role of the central collector, not the data direction. In Client mode, the central collector connects to a shared Broker. In Server mode, the central collector listens and each edge MQTT Client Forwarding connects to it.

Configure MQTT Upload on Each Edge

Perform these steps on every edge Gateway:

  1. In Development configuration → Data forwarding, create enabled group Edge01_Upload. Choose manual variable selection and change triggering. Add the source in the next step; creating the group alone does not select a variable.

Create an enabled edge group with manual scope and change triggering

  1. In Group variable configuration, add source device Collect_OPC_UA and variable Ramp1, enable it and save. Select the original edge point rather than the center mirror to avoid a forwarding loop.

Add the edge source variable Ramp1 to the forwarding scope

  1. Create target Edge01_Broker, select MQTT client forwarding, and enable it. Method-call permission and variable RPC writing are separate settings; method calls can remain disabled for collection.

Select and enable the MQTT client forwarding target

  1. Under Plugin properties, enter the Broker endpoint, a unique Client ID, protocol and required credentials. This example uses TCP, MQTT 3.1.1 and 127.0.0.1:18886.

Edge MQTT Broker endpoint, Client ID and port

  1. Enter the fixed Topics below and leave Retain disabled. Use separate suffixes for write RPC, historical reads and snapshot requests.

Edge write RPC, history and snapshot request Topics with Retain disabled

Fixed variable Topic containing source key edge-01

  1. Under Data and scripts, enable variable-list upload, disable variable-dictionary upload and JSON Ignore Null, and leave the variable entity script empty. Save the target. Keep the default variable-list payload rather than replacing it with a custom value-only JSON object.

Variable-list upload enabled, dictionary upload and Ignore Null disabled

  1. When the target is online, request a snapshot at the center and preview and apply synchronization. If the directory is empty, check the saved group scope, variable-list upload and exact Topics first.

Endpoint Mapping

Central Collection ModeEdge MQTT Client Forwarding EndpointIdentity Configuration
Gateway MQTT collection clientEnter the shared Broker address and port. The central collector connects to the same BrokerUse a unique edge ClientId and the Broker account assigned to this edge. Broker ACLs should restrict the edge to its own {TopicRoot}/{RemoteKey}/# namespace
Gateway MQTT collection serverEnter the central Gateway address and the listener port configured by Gateway MQTT collection serverClientId must equal the source’s AllowedClientId; username and password must also exactly match that source configuration

Do not use MQTT Server Forwarding on the edge. Client collection requires both sides to connect to one shared Broker, while Server collection requires an edge client to connect to the central listener. MQTT Client Forwarding is the connection initiator in both topologies.

Fixed Topics and Payload Shape

If the collector Topic root is TGateway/Gateway and this edge uses RemoteKey=edge-01, configure its MQTT Client Forwarding as follows:

Edge PropertyValue or Requirement
Variable Topic TemplateTGateway/Gateway/edge-01/Variable
Data Request TopicTGateway/Gateway/edge-01/RpcQuest
RPC Write TopicTGateway/Gateway/edge-01/RpcWrite
Historical Read RPC TopicTGateway/Gateway/edge-01/RpcHistory; a valid non-empty prefix
Variable List UploadEnabled
Variable Dictionary UploadDisabled
Variable Entity Script / Upload TemplateEmpty; do not change the current fixed payload
JSON Ignore NullDisabled
Retain MessageDisabled; dedicated collection rejects retained messages
Filter Offline DataDisabled so a full snapshot includes offline variables and their metadata
QoS LevelMatch the edge and the central source; AtLeastOnce is recommended. Repeated older values cannot overwrite current state, but historical backfill can contain duplicates
Upload Shard SizeGreater than 0, with each JSON batch kept below the collector’s Inbound Payload Byte Limit

RemoteKey is not a separate MQTT Client Forwarding property. It is embedded in the fixed Topics above. Every edge Gateway must use a different RemoteKey. Do not use ${...} placeholders in these Topics, and do not change the payload through an entity script or upload template. The dedicated collector does not issue historical-read RPC requests, but the edge forwarding target still requires a valid non-empty prefix in that field. The images use QoS 0; change both the source and target when using QoS 1.

Backfill the central history database

Enable the Edge’s failed-send retry cache, include mapped central variables in an enabled forwarding group, and configure a Historical Data Storage target. Every received sample retains its source value, CollectTime and CreateTime. A list may contain multiple samples for the same variable. Late values do not roll back current state, and unchanged values can still enter history. ChangeTime remains available for custom processing but is not a separate standard history column.

The fixed payload requires CreateTime, CollectTime and ChangeTime as Unix millisecond timestamps; the default Edge variable list supplies them. Backfill stores the processed Edge value without reapplying the center’s read expression. Central scope, enable state and online filtering apply. Scheduled central collection adds local snapshots; use change triggering when only source records are needed.

The Edge cache covers Edge publishing failures. If the shared Broker has acknowledged publication while the central subscriber is offline, delivery also requires a stable central ClientId, a persistent session and suitable Broker offline queues. MQTT publication acknowledgement is not database commit confirmation. QoS redelivery and reconnect snapshots may duplicate history. The general MQTT Collection Client updates variables at receipt time and does not provide this source-time backfill. See Offline cache and historical backfill for capacity and database time columns.

Check the center’s Messages per second limit and concurrent processing capacity for replay peaks. Messages beyond these limits are rejected, and Broker-acknowledged messages do not automatically return to the Edge cache. Configure suitable batch sizes and publishing rates, then inspect rate-limit and rejection counters.

Configure the connection and remote variables

Open the plugin

Open Development Configuration → Collection Configuration, create one collection device, and select Gateway MQTT Collection Client.

This is a shared-connection plugin: configure multiple remote sources inside this one device. Do not create one ordinary MQTT channel or one Gateway MQTT device for every edge Gateway.

Configure the edge target as described in Configure MQTT Upload on Each Edge.

Select Gateway MQTT collection client for a device under No channel

Enter the shared Broker connection under Plugin properties. Use different center and edge Client IDs.

Center Gateway MQTT client shared Broker connection

Connection and security

SettingDescription
Connection typeDefault Tcp. Select TCP or WebSocket according to the shared broker.
IP addressDefault localhost. Host name or IP address of the shared broker.
PortDefault 1883. Broker port.
WebSocket pathDefault /mqtt. Used only for WebSocket connections.
Client IDPersistent client ID for the central collector. It must be unique on the broker.
Clean sessionDefault enabled. Controls the shared MQTT session state.
MQTT versionDefault 4 (MQTT 3.1.1). Must match the broker.
Enable SSLEnables TLS for the shared connection.
SSL target hostHost name used for certificate validation.
Client certificate / CA certificateSelect the trusted Broker CA for TLS. Select a client identity only if the Broker requires mutual TLS.
Allow untrusted certificateTemporary commissioning option. Disable it in production.
SSL protocol / revocation checkTLS and certificate-revocation controls required by the broker.
Username / passwordCredentials for the central collector on the broker.
Keep-aliveDefault 60 seconds.
Connection timeoutDefault 3000 ms.

Remote sources and protocol

SettingDescription
Topic rootDefault TGateway/Gateway. It must be identical on the central collector and all edge forwarding targets.
Remote sourceOpens the source list. Add one source for each edge Gateway.
RemoteKeyStable identifier used in topics, variable addresses, snapshot requests, and RPC. It must be unique and contain only ASCII letters, digits, hyphens, or underscores.
Display nameHuman-readable source name shown in the debug page.
EnableEnables subscription, snapshots, catalog updates, and RPC for this source.
QoSQoS used by this source’s fixed protocol messages.
Allow remote writeEnables write requests from the central collector to edge variables. Keep it disabled unless required.
Snapshot intervalDefault 60 seconds; range 10–3600. Periodic full catalog snapshot interval.
Request timeoutDefault 30 seconds; range 1–600. Timeout for snapshot and RPC requests.
Offline timeoutDefault 180 seconds. Must be greater than the snapshot interval.

Each remote source must have a different RemoteKey. The collector uses one shared MQTT session, while source identity is carried by the protocol namespace.

Open the remote-source editor and add enabled source edge-01. Match the source key to the Topic namespace.

Center client remote source key, display name, QoS and enable switch

Match the Topic root and leave remote writing disabled while setting up collection.

Center Topic root and remote-write switch

Capacity limits

SettingDefaultDescription
Remote source limit32Maximum configured edge sources for this device.
Snapshot concurrency4Maximum simultaneous snapshot or synchronization tasks.
Inbound payload limit1048576 bytesMaximum size of one incoming MQTT payload.
Messages per second200Total message rate entering the parser.
Inbound handler concurrency4Maximum concurrent JSON handlers.
JSON depth limit64Maximum accepted protocol JSON nesting depth.
Per-source catalog limit100000Maximum variables in one edge source catalog.
Total catalog limit300000Maximum variables across all sources. It must cover one source limit.
Pending RPC limit256Maximum simultaneous remote RPC batches.
Detailed logDisabledEnables protocol summaries without full sensitive payloads. Disable after commissioning.

Increase limits only after checking memory, broker traffic, and the number of edge sources.

Address rule

Use the remote source key and remote variable ID:

{RemoteKey}/{RemoteVariableId}

Example: edge-01/877079827984453 for the remote Ramp1 point on this page.

The variable ID is the ID reported by the edge Gateway. Do not replace it with the local mirror variable ID.

Debug and verify

Device debug

Open Development Configuration → Collection Configuration, select the Gateway MQTT device, open Protocol Debug at the top of the workspace.

Gateway MQTT client showing online source edge-01 and snapshot controls

Use Remote gateways to check source connectivity and request snapshots; Remote variables to inspect the source catalog; Variable synchronization to review and apply local changes; and Diagnostics to identify rejected messages or RPC failures.

Write an edge variable from the center

Ramp1 is read-only. Create a separate writable Setpoint to follow the complete path from the central write through the edge protocol to the peer value. The central mirror uses the remote variable ID, not a Modbus address.

  1. Prepare the edge data source. In Modbus Slave 7.4.1 → Setup → Slave Definition (F8), set Slave ID 1, function 03 Holding Register (4x), decimal address 0 and quantity 100. Zero-based offset 2 in this example corresponds to 40003 in the Modbus master.

Modbus Slave station1 FC03 zero-based start and100 holding registers

  1. In Connection → Connect, select Modbus TCP/IP and listen on 127.0.0.1:15020. Use the tool computer’s actual IP when it runs separately from the edge Gateway. Follow Modbus Master to create the edge TCP client channel and station 1 device.

Modbus Slave TCP/IP listener address and port15020

  1. Add Setpoint under edge device Edge_Modbus_Setpoint: address 40003, type Int16, array length 1 and Read/Write access. Enable its RPC write switch further down the form, save it and include it in Edge01_Upload. Keep the edge target’s write Topic TGateway/Gateway/edge-01/RpcWrite.

Edge Setpoint device address40003 Int16 and ReadWrite access

Enable RPC write on the edge source variable

  1. Enable Allow remote write in the central client’s Plugin properties and save the device. This device switch does not change individual variable permissions.

Central client Topic root and enabled remote-write switch

  1. Request a full snapshot in Protocol debug → Remote gateways, then synchronize this source. Review additions, updates and conflicts in Variable synchronization before Confirm and apply. This plan adds Setpoint and leaves the existing Ramp1 unchanged.

Client synchronization plan adds one Setpoint and retains one existing variable

  1. Edit the new mirror. Its address is edge-01/877159968292933, using the edge Setpoint ID after the slash. Keep the synchronized Int16 scalar configuration, change local access to Read/Write and enable the mirror’s RPC write switch. New synchronized points default to read-only with RPC write disabled; writable source metadata does not open local permissions automatically.

Central mirror uses RemoteKey and remote variable ID with ReadWrite access

RPC write switch for the central Setpoint mirror

  1. Filter Realtime variables by Setpoint, select Write, enter integer 43 and submit after the form recognizes it as a number. Use the source type for strings and true/false for Boolean values; arrays must match the source element type and count.

Write43 to the central client Setpoint mirror

  1. After success, read back the mirror and check zero-based address 2 in Modbus Slave. Both should show 43. A value merely entered into the central dialog does not show the peer’s actual value.

Central client Setpoint mirror reads back43

Modbus Slave offset2 receives43 while offsets0 and1 retain their values

For write disable, check Read/Write and RPC write permissions on both the mirror and source. For RPC timeouts, inspect source connectivity, fixed Topics, edge responses and central diagnostics. After editing a variable, let a new snapshot or upload initialize the mirror before assessing its collection state.

Troubleshooting

SymptomCheck
Shared connection cannot startBroker address, port, Client ID, credentials, TLS, CA certificate, and broker ACL.
Source remains offlineRemoteKey spelling, Topic root, edge target state, snapshot interval, and edge protocol messages.
Catalog is emptyEdge forwarding range, variable-list upload, snapshot response, payload limit, and catalog limits.
Values from sources are mixedEvery source must use a unique RemoteKey; every mirror address must use the matching RemoteKey.
Snapshot times outEdge target connectivity, request timeout, message rate, inbound payload size, and broker traffic.
Remote write failsCentral and edge remote-write switches, source metadata permission, local variable permission, and RPC response logs.
Source becomes degradedOffline timeout, snapshot completion, edge reconnect state, and diagnostics.