Troubleshooting
Sparkplug node stuck on Connecting while MQTT connects
Short answer
The node-red-contrib-sparkplug node takes its broker string literally and adds no transport scheme, so a bare IP:port is rejected before any connection attempt and the node sits on Connecting with no error. Write the broker as a full URI — tcp://192.168.1.50:1883 for plaintext or ssl://host:8883 for TLS — deploy, and it connects where the default MQTT node already did.
On this page
When node-red-contrib-sparkplug sits on Connecting forever while the default MQTT node connects to the same broker, the broker address is the cause. This node takes the string in its broker field literally and adds no transport scheme of its own, so a bare address of IP and port never becomes a connection attempt: no socket opens, nothing times out, nothing logs an error, and the status under the node stays where it is. The MQTT node that ships with Node-RED fills in a plaintext scheme for you, which is why it connects where the Sparkplug node stalls. Write the broker as a full URI with the scheme included — tcp:// for a plaintext listener — deploy, and the node connects on the same network, to the same broker, with the same credentials it already has.
Why it stalls on Connecting instead of reporting an error #
The package's documented behavior is to connect automatically when the flow deploys, so a node that never leaves Connecting is a connect that never started. The client this node drives expects the broker as a URI: a scheme, then ://, then the host, then a colon and the port. Hand it a bare address and there is no scheme to act on, so the string is rejected before any socket opens. Nothing is pending, so no timeout fires and nothing is logged, and the status stays on Connecting indefinitely.
The asymmetry with the default MQTT node explains the confusing half of the symptom. That node accepts a bare host and assumes plaintext, so it reaches the broker and publishes — in vanilla MQTT format, which a Sparkplug host discards as unparseable. The default node connecting is therefore not evidence that the Sparkplug node's address is fine. The two nodes treat the same string differently, and only one of them copes without the scheme.
Write the broker as a full URI #
Correct the string, redeploy, and the stall ends:
- Open the Sparkplug node's configuration in the Node-RED editor and edit its broker setting.
- Replace the bare address with the full URI. For a plaintext broker at 192.168.1.50 listening on port 1883, enter
tcp://192.168.1.50:1883. - For a broker that requires TLS, use
ssl://in place oftcp://and keep the TLS listener's port, and make sure the Node-RED host trusts the broker's certificate; the page on configuring MQTT TLS certificates in Node-RED covers that side. - If the host is an IPv6 address written out literally, wrap it in square brackets:
tcp://[fe80::1]:1883. A DNS hostname goes in as written, without brackets. - Deploy the flow. The node connects on deploy, and the status under it should leave Connecting promptly.
When you later point the node at a different broker, write that listener's URI in full the same way — a scheme-less address stalls identically on the new host — and re-check the death and rebirth behavior a broker change can disturb, as covered in rebirth failures after switching Sparkplug MQTT brokers.
The URI forms the node accepts #
tcp://host:port— plaintext MQTT. This is the form for a broker's plaintext listener, normally port 1883.ssl://host:port— MQTT over TLS. This is the form for the TLS listener, normally port 8883.tcp://[address]:port— square brackets are required when the host is an IPv6 literal; a resolved hostname needs none.
The scheme, not the port number, decides whether the client connects in plaintext or negotiates TLS, so match the scheme to the listener and the port to a listener the broker actually runs. A bare endpoint string is a recurring failure across plant software, not only here; the same discipline of writing the transport into the address appears in fixing transport URI and endpoint errors on an OPC UA server.
Example: writing the broker URI for 192.168.1.50 on 1883 and 8883 #
Inputs: the broker host is 192.168.1.50, the address from the failing configuration; the broker runs two listeners, plaintext MQTT on port 1883 and MQTT over TLS on port 8883, the two standard MQTT ports.
The rule: build the broker string as scheme + :// + host + colon + port. The scheme names the transport — tcp for the plaintext listener, ssl for the TLS listener — and the port must be the one that listener actually uses. An IPv6 host would be wrapped in brackets; this host is IPv4, so none are needed.
The arithmetic, one line per listener:
- plaintext: tcp:// + 192.168.1.50 + : + 1883 gives
tcp://192.168.1.50:1883 - TLS: ssl:// + 192.168.1.50 + : + 8883 gives
ssl://192.168.1.50:8883
Result: two paste-ready broker strings, one per listener.
Decision: if the broker field holds the bare address 192.168.1.50:1883, the node stalls on Connecting, because the string carries no scheme. Either URI above connects the node — the tcp form against the plaintext listener, the ssl form against the TLS listener with the broker's certificate trusted on the Node-RED host. If the field holds any address without ://, fix that before touching the network, the credentials or the broker.
If the URI is right and the node still says Connecting #
Then the address parses and a connect is genuinely attempted, so the question moves off the string. Work down this list:
- Reachability: from the Node-RED host, confirm something answers on the port in the URI. A successful TCP connect is not proof of a working broker link; the next step is diagnosing an MQTT connect that fails while TCP itself works.
- Identity: confirm the username and password, and that the broker accepts this client's identifier rather than dropping the session as a duplicate or unauthorized one.
- TLS trust: with ssl://, a certificate the Node-RED host does not trust ends the connect at the TLS step, so verify the certificate chain before changing broker settings.
- Broker side: confirm the listener is enabled and the client is allowed to publish to this node's Sparkplug topics.
Each of these fails loudly once the URI is correct — a refused socket, a TLS alert, a CONNACK carrying an error code — which is what separates them from the silent stall the bare address produces.
Connected is not the finish line #
When the status finally leaves Connecting you have an MQTT session, not yet Sparkplug data. The node publishes its birth certificate, the primary host answers with its STATE, and only after the host accepts the node's group and edge identity do tags fill. Keep the checks client-side and in order: a Sparkplug host discards payloads that arrive in plain MQTT format, so publishing vanilla MQTT through the default node fills nothing even while connected. The URI was the first client-side fault; device tags and naming are the next, and fixing Sparkplug B device tags on the client side walks that side of the link. If the broker accepts plain MQTT but no birth certificate ever arrives, confirm the host actually speaks the protocol, because MQTT broker support is not Sparkplug support.
The decision, case by case: a bare address in the broker field — write the full URI and redeploy, and the Connecting stall ends. A full URI that still shows Connecting — chase the handshake, the credentials or the TLS trust, in that order. Connected but no data — fix the client's Sparkplug side, never the broker.
Questions asked
Does the default MQTT node also need the tcp:// prefix?
No. The MQTT node that ships with Node-RED assumes a plaintext connection when you enter a bare host, so it connects where the Sparkplug node stalls. Writing the full URI in both nodes still pays off: the two configurations stay identical, and an address copied from one node to the other cannot change meaning on the way.
What changes for a TLS broker on port 8883?
Replace the tcp scheme with ssl and keep the TLS listener's port, giving ssl://192.168.1.50:8883 for the broker in the worked example. The scheme, not the port number, tells the client to negotiate TLS before the MQTT handshake. The Node-RED host must also trust the broker's certificate, or the connect fails at the TLS step instead of stalling.
Can I enter a hostname instead of an IP address?
Yes. The scheme rule is the same: tcp://broker.plant.local:1883 connects like the numeric form. Brackets are only for IPv6 addresses written out literally, such as tcp://[fe80::1]:1883; a DNS name goes into the broker field as written and is resolved when the node connects.
Why is there no timeout or error while it sits on Connecting?
The malformed address is rejected before the client opens a socket, so no connection attempt is running and nothing can time out. The status is not stuck mid-handshake; the handshake never began. Correcting the URI starts the attempt, which is why the node then either connects or fails with a real cause.
Do I need to update or reinstall the package to fix this?
No. Entering the broker as scheme://host:port is the input the node expects, so the installed version behaves correctly once the string is right. Redeploy the flow after editing the broker setting and watch the status leave Connecting. Update the package only if a separate, documented fault points at the installed release.