New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mqtt5 #2778
Mqtt5 #2778
Conversation
- e.g. @1 denotes alias 1 is set but topic is empty
(@knolleary) Nick, question, should I be updating this PR with changes you guys make to the DEV branch (to keep it up to date)? |
@Steve-Mcl no need - unlikely to get any conflicts as we're not making changes to these files ourselves at the moment. |
@Steve-Mcl I'm testing this this morning and was wondering if it's normal that the MQTT in node and the configuration node shows the User Properties field ? Shouldn't this be visible only on the MQTT out when publishing ? |
Hi @natcl the User Properties are valid for subscriptions (MQTT IN) 3.8 SUBSCRIBE - Subscribe request --> 3.8.2.1.3 User Property The Non-normative comment states
Although I have no means of testing this or fully understand the usage, I imagine its for broker developers to use. When Nick gets around to looking at the work, he/we may decide it is not relevant or useful to include, but as far as the oasis spec goes, it is valid. |
Hi @Steve-Mcl this is next on my list to look at for 1.3.... but there is rather a lot to wade through... good work 😉 Truth be told, I can't remember the semantics of a lot of this stuff as I've not done any thing with v5 for so long. So this is a fun nostalgic trip remembering 18 months of heated technical debate about what should be in v5. At first glance, I think we need to be fairly stringent on what options we choose to expose in the UI - and how we expose them. I'm concerned about throwing everything in there at the cost of making it appear harder to use for the simple cases. It's always easier to iterate to add missing features then it is to remove unused features later on. Here are some initial thoughts - don't take these as immediate calls for action, rather points to discuss.
|
Hi Nick. On a quick read of your points, I agree with much of what you said. What is the timeframe for getting this ready for 1.3 ? |
I'd like to get the beta out as soon as we can. We don't need absolutely everything in the beta, but the more that's in there, the better. Do you think you'll get a chance to make these updates in the next week? Most of it is removing things, so shouldn't been too much work. There's more to do on top of that with updating the help and i18n messages etc. But that's stuff I can help tidy up once the basic function is there. |
Yeah, should be do-able. Does this approach sound ok...
|
Sounds good. Dev should merge in cleanly. |
Hi Nick, I'll post smaller updates for quick review by you - to see if I am heading in an acceptable direction if you don't mind?
Is this an acceptable solution - instead of a "none" and "other" entry, utilise a custom list and |
This is a mock up... The issue I have just thought of with this approach is that we will need an additional boolean for the use/no use checkbox. but, then, if we permit override in 🤔 I will leave these 2 as is until I have removed / tidied the form - perhaps it doesnt look too busy once we have thinned the other options out? Appreciate you feedback. |
Just wondering but perhaps response topic and correlation data could only be passed via msg ? Does it need a UI ? |
Not meaning to be pedantic but as a counter argument, the same could be said for The elements I see as sensible for UI definitely include
Others should perhaps be either accessible via msg params or removed / hidden due to being more "under the hood" than client facing. Thoughts? |
Hi @knolleary I have been mocking and playing with MQTT OUT node. After some play time and re-reading of your comments, I have a proposal I hope is a reasonable compromise. MQTT OUT nodeProperties I believe it makes sense to be on the UI (written in order of appearance)user properties
response topic
correlation data
content type
message expiry (secs)
Rationale & logic on changing all to typedInputs...I believe there are 3 ways this could go
Demo based on the above...I dont think this is too overwhelming? Please let me know your thoughts so I can proceed with the coding. |
Go ahead with what makes sense and can review when you've done it. |
* MQTT IN node tidy up * remove userProperties * remove subscriptionIdentifier * MQTT OUT node tidy up * remove topicAlias * remove payloadFormatIndicator * remove subscriptionIdentifier * MQTT BROKER node tidy up * remove topicAliasMaximum * remove maximumPacketSize * remove receiveMaximum * remove userProperties
Progress... Pretty much everything you suggested has been implemented (perhaps some took a slightly different direction due to re-think / compromise)
msg only v5 options (intended to be undocumented / experimental)...
demo flows...
important note. publishing a topicAlias before registering it will crash node red. This is handled in MQTTJS #1176 (due for release soon) |
I don't immediately see why we should expose this if the client is handling aliases under the covers. To do aliasing properly, the client needs to know if the broker supports them and if so, what limits it imposes. Allowing the user to specify their own aliases with no regard for what the broker has said is allowed is a recipe for things to fail. |
I left this in (albeit an undocumented feature) as I believe it could be useful for users wanting to perform high speed / reduced traffic mqtt.
The PR does receive the max alias from the broker and stores it to ensure the user cannot use an alias when not not supported or greater than the maximum alias. At present, I cant remember exactly what I do (ignore the transmission or raise an error - but we have options if you have a preference). Also, I am happy to disable this if it permits us to get MQTT5 merged Nick? |
On all the typedInputs - we don't provide flow/global options on every minor option unless there's a compelling use case for why it will be a commonly used choice. Nor do we generally let the user change what So I would like to remove the
My concern is that exposing an option like this, even undocumented, may mean our hands are tied in the future to make the client smarter in its auto-aliasing. I'm happy to merge this as-is and make these changes myself. I note you also saw the require around LWT properties - they asked in Slack at the same time as posting to the forum. I'll take a look at what it'll take to add those options to the broker ui as well. |
@@ -10,6 +10,54 @@ | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
--> | |||
<style> | |||
.form-row label:first-child { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for future reference as I'll tidy it up in merge, but need to be careful not to apply global styles like this. Needs to be more carefully scoped to this node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops on the global style. In my head it only applied to .form-row
and only for this node. After reading your commend and using a bit of brain power, I realise the CSS can affect other nodes when their form is opened.
packages/node_modules/@node-red/nodes/locales/en-US/messages.json
Outdated
Show resolved
Hide resolved
"rap": "Retain as Published", | ||
"rh": "Retain Handling", | ||
"rh0": "0, Always send retained messages", | ||
"rh1": "1, Send retained messages for new subscription", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sense to expose the 'send on new sub' option. We don't let the user dynamically subscribe, so the only time they would have a resubscribe is if they had two identically configured nodes.
I think this option should be simplified to a binary "Send retained messages" options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was purely to follow the oasis specification Nick. It does work as described. But as you have 1st hand knowledge on the design of both node-red and mqtt, I am of course happy to go with your recommendation.
No bother.
Thats fine by me if you want to crack on but I am happy to take a look if you dont have the time? As for topicAlias, I can remove this if that is preferred? Just let me know before 5pm please. Ether way. |
I'm happy to finish this off. I appreciate all your work getting to this point - and it's just a bit of fine tuning from here. |
Co-authored-by: Nick O'Leary <nick.oleary@gmail.com>
It seems sad to me not to support topic aliases, there are a lot of scenarios with embedded devices/PLCs/micro controllers where this could be useful...
…--
lecaude.com
studioimaginaire.com
Le 22 févr. 2021 à 07:39, knolleary ***@***.***> a écrit :
I'm happy to finish this off. I appreciate all your work getting to this point - and it's just a bit of fine tuning from here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@natcl this isn't about not supporting them. It's whether we need to expose it to the end user or not. For every node with a hardcoded topic, we could automatically create an alias under the covers for that node without the user having to do anything. For nodes without a hardcoded topic, we could dynamically generate them as needed - within the limits imposed by the broker. |
What I’m wondering is if you publish to a broker where the number of topic aliases per client is low (10 seems to be the default for mosquitto) The user might want to choose which topic to alias. Perhaps a message sent every second might benefit more from an an alias than a message sent once an hour.
…--
lecaude.com
studioimaginaire.com
Le 22 févr. 2021 à 07:55, knolleary ***@***.***> a écrit :
@natcl this isn't about not supporting them. It's whether we need to expose it to the end user or not.
For every node with a hardcoded topic, we could automatically create an alias under the covers for that node without the user having to do anything.
For nodes without a hardcoded topic, we could dynamically generate them as needed - within the limits imposed by the broker.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
This has now been merged - albeit with a number of changes.
On the question of topicAliases, I've tried to make it a little smart. If the user sends topic="foo" topicAlias=2, we check to see if we already know about topicAlias 2 and if it equals "foo". If it is known and matches, we blank out topic so the alias is used. If it isn't known, or doesn't match, we send topic and alias as-is to update the alias on the broker side. This means a flow that dynamically sets the topic doesn't have to worry about getting the logic right to set topic the first time and not the subsequent times. I have not exposed topic alias in the node ui. I think my earlier ideas of having the client automatically manage the aliases is worthwhile, but also more work than I can consider right now. |
Hi Nick, Happy to see this. Appreciated. I like the changes you made for typedInputs - makes things a bit neater. In my testing I noted a couple of small points... userPropertiesif the user sends however, if we remove them 3 lines and allow the helper function to do its thing... Also, I see you did not use the helper function for the LWT correlationData
LWTIn setting up the lwt messages, this and this look like copy paste issues (setting willMsg by mistake) Otherwise, in my testing, all working nicely. I can raise a PR to these if you wish? |
ISTR there was a reason we needed to do those three lines... but it may be I was still getting to grips with the helper functions and how they worked. I know I misunderstood them at first. Happy to defer to you.
its a buffer in the sense that its just a bag of bytes - it doesn't use the two-byte length header that the protocol uses for other things it calls strings. The question is what does the user actually want to do with it. My gut feel is this will often contain a string for sheer convenience. So I've erred on the side of caution here. On the one had we could add
Yeah - there was lots of copy and paste going on... not 100% surprised I missed something. PRs for the LWT and UserProps would be welcome. Still on the fence over correlData - will be easy enough to add in the future if the need is there. |
Proposed changes
Support major features of MQTT V5
Checklist
grunt
to verify the unit tests passDetails
Summary (from forum thread)
Implementation Notes
this.unsubscribe
//TODO)Issues...
MQTT IN, MQTT OUT, MQTT Broker userProperties
NOTE: userProperties MUST be UTF-8 String pairs https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
Questions...
Should V5 properties passed in a msg be encapsulated in
msg.properties
?msg.userProperties
,msg.topicAlias
etc then manipulated into the MQTT packet underoptions.properties
Should V5 properties returned from a subscrption be in
msg.properties
?msg.userProperties
,msg.topicAlias
Should other properties (retain handling, subscription ID, content type, alias etc) also be typedInputs?
msg.topicAlias
,msg.subscriptionId
etc then we have to deal with that forever more if we are to maintain backwards compatibility.msg.properties
, this is only one property that needs future handling.Other / TODO
Reference Materials...
Forum discussion: https://discourse.nodered.org/t/node-red-mqtt-5-support/17847/
Oasis Standard (current): https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html
MQTT.js reference: https://github.com/mqttjs/MQTT.js#client