Deployment
The node runs as a container in either of two modes. Inside Litmus Edge it finds the instance on its own, needing no hostname and no NATS credentials — the normal production deployment. Outside Litmus Edge it reads the same devices and publishes the same Sparkplug messages, but you supply the Litmus Edge address and credentials for its NATS broker.
See Quick Start for requirements and Marketplace setup. See Configuration for all environment variables and defaults.
Inside Litmus Edge
Use these steps when you manage the container yourself rather than through the Marketplace.

- In Litmus Central, select version 2.0.2 and download le-sparkplug-2.0.2-amd64.tar.gz or le-sparkplug-2.0.2-arm64.tar.gz, matching the Docker host's architecture.
- In Litmus Edge, navigate to Applications > Images, then upload and import the archive.
- Navigate to Applications > Containers, click Run, and enter the command. See Overview of docker run.
docker run -d --name le-sparkplug --restart unless-stopped \
-v le-sparkplug-data:/le-sparkplug/data \
-e EDGE_API_TOKEN="<Litmus Edge API token>" \
-e GROUP_ID="Plant1" \
-e NODE_ID="Line1" \
-e MQTT_URL="tcp://192.168.1.20:1883" \
le-sparkplug:v2.0.2If you use the registry instead of importing the archive, download Registry Access from the same version in Litmus Central and follow its instructions. Use us-docker.pkg.dev/litmus-customer-facing/litmus-solutions/le-sparkplug:v2.0.2 in place of the local image name. There is no latest tag.
The node reaches Litmus Edge through the Docker gateway, which it detects from the container's default route. Set EDGE_DOCKER_GATEWAY_IP to name that gateway explicitly when detection does not find the right one.
Add -p 9090:9090 to reach the metrics and health endpoints from outside the container.
Outside Litmus Edge
External mode adds two things to the deployment above: the Litmus Edge address, and credentials for its NATS broker. Beyond the Quick Start prerequisites, it needs:
- Docker on the external host, with network access to the Litmus Edge HTTPS API (default port 443), the Litmus Edge message broker (default port 4222), and your MQTT broker.
- A token for the Litmus Edge message broker from an API Account. This token is separate from the Litmus Edge API token. In Edit Topics for the account, grant read access to system.events, each DeviceHub data subject you publish (for example, devicehub.alias.Line1.>), and the runtime subjects for any Digital Twins you publish. A new account has no topic permissions. The node does not need write access.
- The NATS proxy enabled on the Litmus Edge instance. See Tokens.
Download the same architecture-specific archive described above. For example, on an amd64 host:
docker load -i le-sparkplug-2.0.2-amd64.tar.gzDocker reports Loaded image: le-sparkplug:v2.0.2. Start the MQTT subscriber from Quick Start before you start the node so it receives the birth messages.
Run the node with your own endpoint, tokens, and MQTT settings. If Litmus Edge or MQTT must be reached by Docker container name, add --network <shared-network> to join the existing Docker network. If host port 9090 is in use, choose a free port and use it for the health check.
docker run -d --name le-sparkplug --restart unless-stopped \
-v le-sparkplug-data:/le-sparkplug/data \
-p 127.0.0.1:9090:9090 \
-e EDGE_EXTERNAL="true" \
-e EDGE_URL="https://edge-01.plant.example.com:443" \
-e EDGE_API_TOKEN="<Litmus Edge API token>" \
-e EDGE_ACCESS_ACCOUNT_TOKEN="<Litmus Edge message broker token>" \
-e GROUP_ID="Plant1" \
-e NODE_ID="Line1" \
-e MQTT_URL="tcp://192.168.1.20:1883" \
le-sparkplug:v2.0.2Setting | Effect |
|---|---|
EDGE_EXTERNAL=true | Switches to external mode, where the Litmus Edge address must be given explicitly |
EDGE_URL | HTTPS address of the Litmus Edge API. Required in external mode |
EDGE_ACCESS_ACCOUNT_TOKEN | Token for the Litmus Edge message broker |
The generated broker URL uses the hostname from EDGE_URL and port 4222. A port in EDGE_URL applies only to the API. The node escapes special characters in the broker token and sends it as the password without a username.
The generated NATS connection is encrypted, but the node does not verify the Litmus Edge certificate, because Litmus Edge presents a self-signed certificate. The same applies to its calls to the Litmus Edge API.
Connect with an Explicit NATS URL
Set EDGE_NATS_URL to a complete broker connection URL when the generated connection does not fit, such as when the broker listens on another port. This replaces EDGE_ACCESS_ACCOUNT_TOKEN, but you still need EDGE_URL for API calls.
For the Litmus Edge proxy, use tls://:<encoded-broker-token>@<host>:<port>. Keep the colon before the token: this puts the token in the password field without sending a username. Percent-encode special characters in the token when composing this URL yourself. nats:// connects without TLS.
Persist the Data Directory
The node keeps its Sparkplug state in /le-sparkplug/data. Every deployment path mounts the Docker volume le-sparkplug-data there, which is also what the Marketplace application does.
Path in the container | Contents |
|---|---|
seqNum/<group>-<node>_bdSeq.txt | The birth/death sequence number for the next MQTT session |
<group>-<node>_db/ | The store-and-forward buffer, when that feature is enabled |
config/config.json | The configuration file, when you use one |
Sparkplug requires the birth/death sequence number to keep advancing from one session to the next. Lose this volume and the node restarts that counter, so host applications read the new session as out of order and mark the node stale. Keep the volume, and its name, across upgrades.
Never run two nodes with the same Sparkplug Group ID and Node ID, and never point two containers at the same volume. Either one puts two Sparkplug identities on the same topics and corrupts the sequence-number state.
A configuration file goes at config/config.json inside the volume. See Configuration for the file format.
Upgrade to a New Version
State lives in the volume, not the container, so an upgrade replaces the container and keeps the volume.
- Note the Sparkplug Group ID, Node ID, and volume name of the running container, then stop and remove it.
- Deploy the new version with the same Group ID, Node ID, and volume name.
- Confirm the handover on the broker: NDEATH from the old session, then NBIRTH from the new one, carrying the next birth/death sequence number.
Secure the MQTT Connection with TLS
The node connects over TLS when the broker URL uses the ssl:// or mqtts:// scheme and you supply the certificate authority that signed the broker's certificate. Add a client certificate and key when the broker requires mutual TLS.
Certificates are supplied as Base64-encoded text, not file paths, because the node reads them from settings rather than from disk.
Encode the Certificates
Encode each PEM file, including its -----BEGIN----- and -----END----- lines, as a single line of Base64.
base64 < ca.pem | tr -d '\n'
base64 < client.crt | tr -d '\n'
base64 < client.key | tr -d '\n'The output must be one unbroken string. A Base64 value with line breaks in it fails to decode.
Configure the Connection
Purpose | Marketplace parameter | Environment variable |
|---|---|---|
Broker URL, TLS scheme | MQTT Broker URL | MQTT_URL |
CA certificate | MQTT CA Certificate | MQTT_CA_CERT |
Client certificate | MQTT Client Certificate | MQTT_CLIENT_CERT |
Client private key | MQTT Client Key | MQTT_CLIENT_KEY |
Skip verification | not exposed | MQTT_SKIP_CERT_VERIFY |
The equivalent config.json fields sit on each broker object — see Configuration.
The URL scheme decides whether the connection is encrypted at all: ssl:// and mqtts:// use TLS, tcp:// and mqtt:// do not. No other schemes are accepted, so a tls:// broker URL is rejected at startup.
The client certificate and key are read only when a CA certificate is also set. Supplying a client pair on its own leaves the connection without client authentication, and nothing in the configuration is rejected.
MQTT_SKIP_CERT_VERIFY turns off verification of the broker's certificate. The connection stays encrypted, but the node accepts any certificate the broker presents. It is deliberately absent from the Marketplace form, so setting it takes a configuration file or a self-managed container.
Skipping verification removes protection against an attacker impersonating your broker. Use it only to isolate a certificate problem in testing, and never in production. The fix in production is to supply the correct CA certificate.
Multiple Brokers with Different Authorities
A configuration file carries one certificate set per broker, which is the reason to prefer a file when brokers have different certificate authorities.
{
"edge_api_token": "<Litmus Edge API token>",
"group_id": "Plant1",
"node_id": "Line1",
"mqtt": {
"servers": [
{
"url": "ssl://broker-a.example.com:8883",
"user": "sparkplug",
"password": "<password>",
"ca_cert": "<Base64 CA certificate>",
"client_cert": "<Base64 client certificate>",
"client_key": "<Base64 client key>"
},
{
"url": "ssl://broker-b.example.com:8883",
"ca_cert": "<Base64 CA certificate>"
}
]
}
}The node publishes to one broker at a time and moves to the next in the list when the session ends.
Certificate Errors
A successful TLS connection logs connected from the mqtt component with the ssl:// URL in the server field, followed by birth set published. Certificate problems are logged and do not stop the node from starting:
Message from mqtt | Meaning |
|---|---|
decode CA_CERT base64 | The CA value is not valid Base64. The node continues with the system trust store, and the client certificate is skipped |
decode CLIENT_CERT base64 | The client certificate value is not valid Base64 |
decode CLIENT_KEY base64 | The client key value is not valid Base64 |
load client certificate and key | The pair decoded but do not form a usable key pair, so the certificate and key do not match |
The first three are most often caused by line breaks surviving the encoding.
Verify the Deployment
Follow Quick Start steps 2 and 3. On a separate Docker host, run docker logs le-sparkplug to read the logs. Check the health endpoint from that host:
curl -i http://127.0.0.1:9090/healthz200 ok means the MQTT session is up. 503 unavailable means it is not, or that host application gating is enabled and the host has not reported online yet.
In external mode, if the nats component never logs connected, check the broker token and the NATS proxy. If nats connects but the birth set reports no devices, check the API token and EDGE_URL.
Remove
For a container on Litmus Edge, follow Remove in Quick Start. For a container on a separate Docker host, run the following commands. Remove only resources that no other container uses. Deleting the volume permanently deletes the birth/death sequence, buffered data, and stored configuration.
docker stop le-sparkplug
docker rm le-sparkplug
docker volume rm le-sparkplug-data
docker image rm le-sparkplug:v2.0.2If you pulled from the registry, use the full registry image name in the last command. In Litmus Edge, delete the API token and API Account if you created them only for this deployment. Confirm the container, volume, and image no longer appear in docker ps -a, docker volume ls, and docker image ls, and that the credentials no longer appear in Access Control.