Troubleshooting
Why a Node-RED MQTT to OPC UA variable never appears
Short answer
A successful UAExpert connection with a BadNodeIdUnknown read means the MQTT data reached your flow, but the OpcUa-Item node never created the variable at the NodeId you requested. The fault is in address-space creation: the NodeId you read must match the NodeId the item node registers with the server, in a namespace the server actually defines.
On this page
If UAExpert connects to your Node-RED OPC UA server but a manual read of ns=2;s=temp.1 returns BadNodeIdUnknown, your MQTT data is arriving and your server is reachable. The variable is missing because the OpcUa-Item node never created an address-space node at that NodeId, or it created one under a different identifier. Fix address-space creation and identity, not connectivity.
Separate the two paths #
Your flow has two independent paths, and a symptom in one does not diagnose the other:
- The data path: MQTT broker, the
mqtt innode, the OpcUa-Item node, the OpcUa-Server node. - The client path: UAExpert, the server endpoint, the address space.
A message visible after the mqtt in node proves only the data path's first hop. A successful UAExpert connection proves only the client path's first hop. Your fault sits where the two meet: the server's address space. Connectivity settings such as the broker keepalive or the server port cannot create a variable that was never registered.
Check the NodeId you read against the NodeId you configured #
In the exported flow, the item node's configured item is ns=2;s=elsystemp, while the read that failed targeted ns=2;s=temp.1. Those are two different string identifiers in the same namespace index; a read of one can never return the other. The node's display name, temp.1, is a label for browsing only, and it is not an address. Decide on one NodeId, configure it in the OpcUa-Item node, and read exactly that string.
The namespace index is the second trap. Index 2 means whatever the running server's namespace table says it means. In node-opcua, the SDK behind node-red-contrib-opcua, the address space is strict: a namespace that the server has not defined cannot be used, and adding a variable into an undefined namespace fails rather than silently succeeding. Read the server's namespace array with UAExpert, confirm which index your flow's namespace occupies, and use that index. A NodeId copied from another server or an example flow frequently points nowhere.
Follow the message from MQTT input to server #
Enable the Debug nodes in the flow and trace one publication end to end. The mqtt in node subscribes to topic application/7/device/device4/rx at QoS 2 with JSON output, so the payload arriving at the item node is a JSON object, not a bare value. Your item node or a function node must select the field you want and convert it before the server stores it.
The OpcUa-Item node attaches addressing and datatype information to the message; the OpcUa-Server node executes the operation. To add a variable, the command goes in msg.payload with the NodeId in msg.topic, and the server's response tells you whether creation succeeded. Put a Debug node between the item node and the server node, not only downstream of the server, and read that response. Server output in the Debug sidebar is operational information; its presence is not proof that a variable exists.
Confirm with a browse, not a manual read #
Before trusting any manual NodeId, browse the server's address space in UAExpert and find the variable your flow created. Record both its NodeId and its namespace URI. Then compare, character by character, with the NodeId you are reading. This single comparison resolves most BadNodeIdUnknown cases: wrong server instance, wrong namespace index, or an identifier that was never provisioned.
For a deeper look at that exact status code, the guide on resolving OPC UA BadNodeIdUnknown in UaExpert tag reads walks through the client-side checks step by step. The same logic applies here, with the added step that your server builds its address space at runtime from the flow, so the server side is yours to inspect in Node-RED.
If you are troubleshooting the general connection instead, the article on Node-RED OPC UA connection failures covers endpoint and certificate problems that stop UAExpert before it can browse. Your case is past that stage: the client connects.
Where a message can stop before becoming a value #
Work down this list in order; each step isolates one boundary:
- No message after
mqtt in: broker connection, topic spelling, or the publisher. Publish a test message to the configured topic and watch the Debug node. - Message arrives as an object: JSON field selection. Add a function node to extract and convert the value.
- Item node passes the message but the server reports an error: namespace not defined, or malformed NodeId. Fix the namespace first.
- No server error, but browsing finds nothing: the creation command never fired. Check that
msg.payloadcarries the command andmsg.topicthe NodeId. - Browse finds the variable but a manual read fails: you are reading a different NodeId, or a different running server. Compare strings and endpoints.
The decision #
Read the browsed NodeId, not the one you assumed. Correct the OpcUa-Item configuration so the created node and the read request carry the same string identifier in a namespace the server defines, verify variable creation through the server's response on a Debug node between item and server, and confirm in UAExpert by browsing before reading. When those three checks pass, one MQTT publication ends in a value you can read over OPC UA.
If instead you want a ready-made bridge, replacing the flow is a valid second step, but do it after this diagnosis: a replacement bridge must still solve the same two problems, payload mapping and address-space creation, and a connected client with an unknown NodeId will fail on it identically until its variable mapping matches what the client reads. Related reading on the value side: why a Node-RED OPC UA server updates values only when a client reads, which explains the server-side behaviour once your variable exists.
Questions asked
Why does my OpcUa-Item node show a Debug message but UAExpert still finds no variable?
The Debug output confirms a message moved through the flow, not that the server created an address-space node. In node-red-contrib-opcua a variable is created when the item node passes a node creation command in msg.payload together with the NodeId in msg.topic to the OpcUa-Server node, and the server confirms it. Enable a Debug node between the item and server nodes and read the server's response to that command before checking UAExpert again.
How do I find the correct namespace index for my NodeId?
Connect with an OPC UA client, read the server's namespace array, and match each namespace URI to its index on that running server. An index such as 2 is local to one server instance and can point to a different namespace after a configuration change or on another host. The safest identifier is a string NodeId in a namespace your own flow explicitly defines.
Can an OPC Classic sniffer browse a Node-RED OPC UA server?
No. A sniffer built on OPC Classic and DCOM speaks a different protocol and cannot see a UA endpoint at all. Use an OPC UA client such as UaExpert to connect to the endpoint address the Node-RED server actually advertises. A client that connects but reads BadNodeIdUnknown has a reachability path that works; only the NodeId is wrong.