Repository navigation
Closed
Labels
Description
Current Behavior
Using MQTT v5 there are three places that userProperties may be set
- In the mqtt server config node
- In the mqtt out node
- In the message passed to the mqtt out node
The problems are
a. Case 1 does not work at all
b. Case 2 works
c. case 3 works provided there are no properties specified in the mqtt out node Moved to #5435
Expected Behavior
User Properties should add to or but not replace properties set at a lower level. In other words properties set in the message should add to or override properties set in the mqtt node or the server, and properties set in the mqtt out node should add to or override those set in the server.
Steps To Reproduce
Import the flow below. The server is configured for localhost v5 with a user property configured.
- Click the first inject node. Neither the message nor the mqtt node apply properties so the property in the server should be used. This does not appear to work.
- Click the second inject node. In this case the mqtt node applies properties. These appear correctly, but the server node property does not.
- Click the third inject node. Here the message adds a property and also attempts to override a property set in the mqtt node. Only the node set properties appear, the message properties are ignored. The new property set in the message should be added, but the property set in the mqtt node should not be overwritten.
- Click the fourth inject node. This applies properties via the message, with none in the node. This works correctly, apart from that set in the server not appearing.
Example flow
[{"id":"101662ea1a601b72","type":"group","z":"bdd7be38.d3b55","name":"MQTT V5 user properties test","style":{"label":true},"nodes":["bd4e091b8f34d0f6","36235538daae95f6","7c589f639b71196f","b901d49cc8ef4bb0","680554c9b3efe275","50839f1fc7eea6c0","9c280e478b3ffd3e","644efb312c8bbd20","a04f9a771f7af022"],"x":14,"y":1759,"w":612,"h":342},{"id":"bd4e091b8f34d0f6","type":"mqtt out","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"localhost V5 with nodeSetProperty","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"{\"nodeSetProperty\": \"node\", \"propertyOne\": \"One set in out node\"}","correl":"","expiry":"","broker":"eb44199345bf39bb","x":460,"y":1880,"wires":[]},{"id":"36235538daae95f6","type":"inject","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"set propertyOne and Two","props":[{"p":"topic","vt":"str"},{"p":"payload"},{"p":"userProperties","v":"{\"propertyOne\": \"One\", \"property2\": \"Two\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/topic","payload":"","payloadType":"date","x":170,"y":1920,"wires":[["bd4e091b8f34d0f6"]]},{"id":"7c589f639b71196f","type":"mqtt in","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"","topic":"test/topic","qos":"2","datatype":"auto-detect","broker":"eb44199345bf39bb","nl":false,"rap":true,"rh":0,"inputs":0,"x":110,"y":2060,"wires":[["b901d49cc8ef4bb0"]]},{"id":"b901d49cc8ef4bb0","type":"debug","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":260,"y":2060,"wires":[]},{"id":"680554c9b3efe275","type":"inject","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"No msg properties","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/topic","payload":"","payloadType":"date","x":150,"y":1800,"wires":[["50839f1fc7eea6c0"]]},{"id":"50839f1fc7eea6c0","type":"mqtt out","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"localhost V5 no node property","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"eb44199345bf39bb","x":450,"y":1800,"wires":[]},{"id":"9c280e478b3ffd3e","type":"inject","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"No msg properties","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/topic","payload":"","payloadType":"date","x":150,"y":1860,"wires":[["bd4e091b8f34d0f6"]]},{"id":"644efb312c8bbd20","type":"mqtt out","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"localhost V5 no node property","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"eb44199345bf39bb","x":450,"y":1980,"wires":[]},{"id":"a04f9a771f7af022","type":"inject","z":"bdd7be38.d3b55","g":"101662ea1a601b72","name":"set propertyOne and Two","props":[{"p":"topic","vt":"str"},{"p":"payload"},{"p":"userProperties","v":"{\"propertyOne\": \"One\", \"property2\": \"Two\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test/topic","payload":"","payloadType":"date","x":170,"y":1980,"wires":[["644efb312c8bbd20"]]},{"id":"eb44199345bf39bb","type":"mqtt-broker","name":"localhost v5 with source property","broker":"localhost","port":1883,"clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":60,"cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"{\"source\":\"tigger\"}","sessionExpiry":""}]
Environment
- Node-RED version: 4.1.1
- Node.js version: 22.21.0
- npm version:
- Platform/OS: Ubuntu
- Browser:
Activity
dceejay commentedon Nov 28, 2025
In general properties set in the node should not get overwritten - as the author has presumably set them for a reason - so they should be respected, and not be overwritten by the msg.
colinl commentedon Nov 28, 2025
I may be persuaded of that, but the message should be able to add new properties.
dceejay commentedon Nov 29, 2025
yes - I can't disagree with that.
colinl commentedon Dec 1, 2025
I will rephrase the description to only allow the addition of new properties.
[-]MQTT userProperties all messed up[/-][+]MQTT userProperties set in server node not working, and additional properties cannot be set in mqtt node or in message[/+]colinl commentedon Dec 16, 2025
@dceejay is this in your area of code? If so is it likely to get looked at in the near future?
dceejay commentedon Dec 16, 2025
Hi no. It's @Steve-Mcl for this one I think
colinl commentedon Dec 17, 2025
@Steve-Mcl will be thinking "Oh no, not something else for that fellow to hassle me about".
Dennis-SEG commentedon Dec 17, 2025
Feature Request: Environment/Global Variables for MQTT Node Authentication
Problem
Currently, the Node-RED MQTT broker node requires credentials (username/password) to be hardcoded via the UI. For mass device rollouts, this means:
Proposed Solution
Support for
envvariables and/orglobalcontext variables in the MQTT broker node authentication fields:Or via global context:
Benefits
Use Case: Industrial IoT Deployments
When deploying hundreds of EMS devices:
knolleary commentedon Dec 17, 2025
@Dennis-SEG as that is not related to this issue, can you raise a separate issue for your topic rather than tag it on as a comment here.
thalesmaoa commentedon Jan 14, 2026
I'm sorry, but I'm a little confused. I'm facing the same issue. If I can set it inside server config, why it doesn't work?
colinl commentedon Jan 14, 2026
Because there is a bug in the code. The point of this issue is to report the bugs.
Steve-Mcl commentedon Jan 14, 2026
There may well be a bug (I'd need to do some testing) but do you have an mqtt broker that requires user property values in the connection? It's not typically something you would stumble on.
As stated in the spec https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html:
This ☝️
But yes, on reflection, I can't argue with that either.
@knolleary @dceejay should ask the OP to make a separate FR issue for this specific point? (This issue has a lot of noise)
colinl commentedon Jan 15, 2026
I have a system with multiple brokers (mosquitto) and use Bridging to synchronise data across brokers. In order that I can determine which system is the original source for a topic I add add a
sourceuser property containing the system name. The logical place to put this is in the broker config.I will do that.
Steve-Mcl commentedon Jan 15, 2026
That's not what the server user props are for I'm afraid. They are intended to be part of the CONNECT whereby a very specific broker might use "user properties" during the connect to perform some operation (perhaps check a JWT or other type of identification or logic). They are not there for general common setting.
colinl commentedon Jan 15, 2026
Yes, I think you are right. Since I have no evidence that this does not work correctly I will close this issue.