Skip to main content

Gateway MQTT Collection Server

Purpose

This plugin starts one MQTT listener on a central Gateway and receives variable catalogs, current values, device state, and snapshots from multiple edge Gateways using the ThingsGateway Gateway MQTT protocol. Each edge node connects through its own authorized remote-source identity.

It is not a general MQTT JSON collector. Use MQTT Collection Server for custom Topics and payloads.

Open the plugin

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

This is a shared-listener plugin: configure multiple remote sources inside this one device. Do not create multiple Gateway MQTT server devices on the same listener port.

Configure the corresponding MQTT forwarding target on each edge Gateway. See Gateway MQTT Collection Client, Configure MQTT Upload on Each Edge, for the complete topology and fixed Topics.

Channel and data type

ItemDescription
ChannelEmbedded MQTT listener. Common TCP, UDP, and serial channel fields are not used.
Data typeObject. Variable types and catalogs are supplied by the remote Gateway protocol.

Listener and TLS

SettingDefaultDescription
Connection typeTcpSelect TCP or WebSocket listening.
Port1883MQTT listener port, from 1 to 65535.
WebSocket path/mqttUsed only in WebSocket mode.
Enable SSLDisabledEnables the MQTT TLS listener.
Server certificate-Required for TLS. Select a server certificate from Certificate Management.
CA certificate-Required for TLS. Validates edge-client certificates.
Allow untrusted certificateDisabledTemporary commissioning option. Keep it disabled in production.
SSL protocol / revocation check-Configure according to the project TLS and revocation policy.

Remote sources

Open Remote Sources and add one entry for each edge Gateway allowed to connect.

SettingDescription
RemoteKeyStable protocol key using 1 to 64 ASCII letters, digits, hyphens, or underscores. It is used in Topics, variable addresses, snapshots, and RPC. Do not change it casually after commissioning.
Display nameHuman-readable edge name shown in debug.
EnableEnables connection handling, snapshots, catalog synchronization, and RPC for this source.
QoSQoS used by this source's fixed protocol messages.
Allowed Client IDEdge MQTT Client ID. It must match exactly and be unique on the listener.
Username / passwordIndependent credentials used by this source. Keep them out of screenshots and logs.
Client certificate SHA-256Optional 64-character lowercase hexadecimal fingerprint used to bind the source to one client certificate.

Each source must have a unique RemoteKey, Client ID, and configured certificate fingerprint. Certificate binding requires TLS. If one enabled source uses fingerprint binding, every enabled source must use it.

Protocol and reliability

SettingDefaultRangeDescription
Topic rootThingsGateway/Gateway-Must be identical on the central listener and every edge forwarding target.
Allow remote writeDisabled-Allows the central Gateway to issue edge-variable RPC writes. Enable only with site authorization.
Snapshot interval60 seconds10 to 3600Periodic full-catalog and current-value snapshot interval.
Request timeout30 seconds1 to 600Timeout for snapshot and RPC requests.
Offline timeout180 secondsGreater than snapshot interval, maximum 86400Marks a source offline after no valid protocol message.
Detailed logDisabled-Records protocol summaries without complete sensitive payloads. Disable after commissioning.

Capacity limits

SettingDefaultRangeDescription
Remote source limit321 to 128Maximum configured edge sources.
Snapshot concurrency41 to 32Maximum simultaneous snapshot or sync tasks.
Inbound payload limit1048576 bytes4096 to 16777216Maximum size of one incoming MQTT payload.
Messages per second2001 to 100000Total message rate entering the parser.
Inbound handler concurrency41 to 64Concurrent JSON handlers.
JSON depth limit648 to 256Maximum protocol JSON nesting depth.
Per-source catalog limit1000001 to 1000000Maximum variables in one edge catalog.
Total catalog limit300000At least the per-source limit, maximum 3000000Maximum variables across all sources.
Pending RPC limit2561 to 4096Maximum simultaneous remote RPC batches.

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

Address rule

Use the source key and remote variable ID:

{RemoteKey}/{RemoteVariableId}

Example: factory-a/828746157506629.

The remote variable ID is reported by the edge Gateway. Do not replace it with the central Gateway's local mirror-variable ID. See Collection Configuration for common variable fields, imports, and intervals.

Functions

FunctionPurpose
Remote gatewayUse Remote gateway with an approved test point and confirm site safety before execution.
Remote variablesUse Remote variables with an approved test point and confirm site safety before execution.
Diagnostic logUse Diagnostic log to inspect mapped values, status, counters, recent messages, or the latest result.
Variable synchronizationUse Variable synchronization to inspect mapped values, status, counters, recent messages, or the latest result.

Device debug

Open Development Configuration → Collection Configuration, select the Gateway MQTT server device, and click More Functions, then open Debug → Protocol Debug · GatewayMqttCollectServer.

FeaturePurpose
Remote GatewaysShows identity, connection, Client ID, catalog size, message counters, snapshot time, and errors; requests snapshots or tests RPC.
Remote VariablesQueries the remote variable catalog by source, keyword, and online state.
DiagnosticsShows bounded protocol diagnostic events filtered by source.
Variable SyncPreviews local additions, updates, missing variables, and conflicts, then applies a confirmed synchronization plan.

Gateway MQTT Collection Server protocol debug panel

Request snapshot and Test RPC affect only the selected source. Synchronize all and Apply plan change local variable configuration; review the differences and impact first.

Verify the configuration

  1. Add one source with a unique RemoteKey, Client ID, and credentials.
  2. Confirm that the edge MQTT target uses the same Topic root and RemoteKey and connects to the central listener.
  3. Confirm that the source becomes online and request one full snapshot.
  4. Find one variable under Remote Variables and create or synchronize its local address.
  5. Read the local mirror value and compare it with the edge Gateway.
  6. Test remote writing only when central, edge, target, and variable permissions all allow it.

Troubleshooting

SymptomCheck
Listener cannot startPort conflict, connection type, TLS server certificate, CA, and firewall.
Source cannot connectClient ID, username, password, certificate fingerprint, TLS, and listener state.
Source remains offlineRemoteKey, Topic root, edge target state, snapshot interval, and last valid protocol message.
Catalog is emptyEdge forwarding range, snapshot response, payload limit, and catalog limits.
Values from sources are mixedEvery source needs a unique RemoteKey and Client ID, and each local address must use the matching key.
Snapshot times outEdge connectivity, request timeout, message rate, payload size, and MQTT traffic.
Remote write failsBoth remote-write switches, variable permissions, pending RPC count, and response diagnostics.