Skip to content
Stand with Ukraine flag

XMPP

The XMPP Connector collects data from IoT devices over the XMPP protocol and forwards it to ThingsBoard.

To enable this connector, add it to the connectors list in tb_gateway.json — see the General Configuration reference.

The connector reads its settings from a JSON file. Below is a full example:

{
"server": {
"jid": "gateway@localhost",
"password": "password",
"host": "localhost",
"port": 5222,
"use_ssl": false,
"disable_starttls": false,
"force_starttls": true,
"timeout": 10000,
"plugins": [
"xep_0030",
"xep_0323",
"xep_0325"
]
},
"devices": [
{
"jid": "device@localhost/TMP_1101",
"deviceNameExpression": "${serialNumber}",
"deviceTypeExpression": "default",
"attributes": [
{
"key": "temperature",
"value": "${temp}"
}
],
"timeseries": [
{
"key": "humidity",
"value": "${hum}"
},
{
"key": "combination",
"value": "${temp}:${hum}"
}
],
"attributeUpdates": [
{
"attributeOnThingsBoard": "shared",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
],
"serverSideRpc": [
{
"methodRPC": "rpc1",
"withResponse": true,
"valueExpression": "${params}"
}
]
}
]
}

Configures the gateway’s XMPP account and connection to the XMPP server.

ParameterDefaultDescription
jidgateway@localhostJID (Jabber ID) of the gateway’s XMPP account
passwordPassword for the gateway’s XMPP account
hostlocalhostXMPP server hostname
port5222XMPP server port
use_sslfalseUse legacy SSL instead of STARTTLS
disable_starttlsfalseDisable TLS entirely for the connection
force_starttlstrueAbort the connection if the server does not advertise STARTTLS support
timeout10000Connection timeout in milliseconds
plugins["xep_0030","xep_0323","xep_0325"]XMPP extension plugins to register with the client
"server": {
"jid": "gateway@localhost",
"password": "password",
"host": "localhost",
"port": 5222,
"use_ssl": false,
"disable_starttls": false,
"force_starttls": true,
"timeout": 10000,
"plugins": [
"xep_0030",
"xep_0323",
"xep_0325"
]
}

An array of devices the connector is allowed to communicate with. Any device whose JID is not listed here is rejected.

Each entry in the array configures one device and may contain the following subsections: attributeUpdates and serverSideRpc are optional.

ParameterDefaultDescription
jidJID of the device’s XMPP account
deviceNameExpressionJSON-path expression to extract the device name from incoming messages
deviceTypeExpressionJSON-path expression to determine the device type (profile)
attributesGroup addresses mapped to ThingsBoard device attributes (see below)
timeseriesGroup addresses mapped to ThingsBoard time-series telemetry (see below)

Both attributes and timeseries entries share the same field structure:

ParameterDescription
keyThingsBoard attribute or telemetry key name
valueJSON-path expression to extract the value from the incoming message
{
"jid": "device@localhost/TMP_1101",
"deviceNameExpression": "${serialNumber}",
"deviceTypeExpression": "default",
"attributes": [
{
"key": "temperature",
"value": "${temp}"
}
],
"timeseries": [
{
"key": "humidity",
"value": "${hum}"
},
{
"key": "combination",
"value": "${temp}:${hum}"
}
]
}

ThingsBoard allows the provisioning of device attributes and fetches some of them from the device application. You can treat this as a remote configuration for devices, enabling them to request shared attributes from ThingsBoard. See user guide for more details.

The “attributeUpdates” configuration allows you to configure the format of the corresponding attribute data that will be sent to the XMPP device.

ParameterDefaultDescription
attributeOnThingsBoardShared attribute name to subscribe to
valueExpressionJSON-path expression used to build the message payload sent to the device
"attributeUpdates": [
{
"attributeOnThingsBoard": "shared",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
]

ThingsBoard allows sending RPC commands to the device connected to ThingsBoard directly or via Gateway.

Configuration, provided in this section is used for sending RPC requests from ThingsBoard to the device.

ParameterDefaultDescription
methodRPCRPC method name to bind
withResponsetrueSend the device’s response back to ThingsBoard
valueExpressionJSON-path expression used to build the message payload sent to the device
"serverSideRpc": [
{
"methodRPC": "rpc1",
"withResponse": true,
"valueExpression": "${params}"
}
]