Sparkplug is a protocol that sits on top of MQTT to provide a unified namespace, payload format and operating mode for devices.
If you want to validate your Sparkplug implementation is compliant, the Eclipse Sparkplug project publish a Technology Compatibility Kit to test against. Unfortunately it's a tricky to get working properly, especially when testing broker compliance, which is what I'm interested in.
This is how I got it working on Ubuntu 24.04. It assumes you're running everything on the same computer you're logged into.
Installation
Dependencies:
apt update apt install nodejs npm openjdk-21-jdk-headless npm install --global corepack corepack enable
Create a working folder:
mkdir sparkplug cd sparkplug
Download hivemq-ce:
wget https://github.com/hivemq/hivemq-community-edition/releases/download/2024.9/hivemq-ce-2024.9.zip unzip hivemq-ce-2024.9.zip
Download TCK, note that the 3.0.0 release is broken, it is impossible to test MQTT brokers with it.
wget https://www.eclipse.org/downloads/download.php?file=/sparkplug/snapshot/Eclipse-Sparkplug-TCK-3.0.1-SNAPSHOT.zip -O tck.zip unzip tck.zip
Copy hivemq config:
cp SparkplugTCK/hivemq-configuration/* hivemq-ce-2024.9/conf/
Add sparkplug extension to hivemq:
pushd hivemq-ce-2024.9/extensions unzip ../../SparkplugTCK/hivemq-extension/sparkplug-tck-3.0.1-SNAPSHOT.zip popd
Install the web console:
cd SparkplugTCK/webconsole yarn set version latest yarn install
Running
Run the web console:
cd SparkplugTCK/webconsole export NODE_OPTIONS=--openssl-legacy-provider # HOST=0.0.0.0 # If you want it to bind to anything other than localhost yarn run dev
Run hivemq:
cd hivemq-ce-2024.9 ./bin/run.sh
Testing
Navigate to http://localhost:3000 in your browser. Click the red MQTT
Configuration
tab. Click the Set Default Values
button, then Connect
.
Assuming everything works the MQTT Configuration tab should go green.
Now click the Sparkplug Conformance Profile
. Select the Broker
option to
test a broker. Hivemq is configured to use port 1883, even though it doesn't
actually need it, so any broker you test will need to use a different port. I'm
setting Broker TCP/IP address
to localhost
, and the port to 1884.
Expand the Sparkplug Compliant Test
section and click Start Test
. Nothing
else is required. If your broker fails this, it's in a bad state.
Expand the Sparkplug Aware Test
. Set Group Id
to group_id
, and EdgeNode Id
to edge_id
. You now need to send Sparkplug NBIRTH, DBIRTH, and NDEATH
messages. I've created a simple Python script to do this at
https://github.com/ralight/sparkplug-test It requires the Paho Python client.
After running the client, making sure it is publishing to the broker you are testing not hivemq, the test should succeed.
Logs
Scroll to the top of the page, select the Results Overview
tab. Click the
Create
button, then Download
and you have your broker results.