nats-server
nats-server copied to clipboard
Support MQTT QoS=2
Feature Request
I'm using NATS as an MQTT server together with Home Assistant, and the HASS.Agent Windows companion application. The HASS.Agent application uses QoS=2 when it wants to enable commands to run on the Windows machine from Home Assistant. When this is enabled, the MQTT connection is disconnected and a message about QoS=2 not supported is logged.
Proposed Change:
Support MQTT QoS=2.
Who Benefits From The Change(s)?
People using Home Assistant and HASS.Agent with NATS MQTT service.
Alternative Approaches
None at the moment, because HASS.Agent doesn't support setting QoS level.
Thank you for your interest. Unfortunately, there is no plan to implement QoS2 in NATS Server at this stage.
@kozlovic You shouldn't by any chance have a link to a document that describes why you have no current plans of supporting it? I'm going to assume it's quite tricky with how MQTT is implemented in NATS, but it could also be as trivial that you don't have time to prioritize it.
@robinsmidsrod There is no document per-se. I have written the MQTT code in the NATS Server and I am concerned with the added complexity of QoS2 and that we don't have much time with all other priorities. I will, however, re-open this issue and leave it as enhancement request in case the community wants to contribute with a nice PR ;-)
I think there could be many of us wanting to use NATS for its features and also as a full MQTT broker. What kind of help would be needed for this effort?
@kozlovic still haven't dig into the NATS code but do you consider it would be doable to support the full MQTT spec?
It seem that robinsmidsrod does not need QoS2. Problem is if message arrive with qos2 connection is closed. Would it be possible add configuration option downGradeQos2ToQos1 that will allow treat QoS2 messages like qos1 messages?
@TomasVojacek Your observation is correct. I just need the MQTT broker (NATS) to stay connected, even if it doesn't support QoS=2. If there is a "force downgrade" option in the protocol that HASS.Agent will be able to tolerate and continue working with then that is a workaround for me. But if HASS.Agent ignores that and expects QoS=2 behavior then we're no further in terms of solving my integration compatibility issue. I think QoS=2 support in NATS would be awesome, though.
I will look into more, I don't think a simple downgrade will work, IIRC QoS2 has a 4-way handshake that we would need to support in some form or fashion even if we "downgrade" internally to QoS1.
Can the HASS agent be configured not to use QoS2?
@derekcollison I've posted a request in their bug tracker to set max used QoS-level, but it is (to my knowledge) not yet implemented. Here is the link to their bug tracker: https://lab02research.youtrack.cloud/issue/hassagent-118
ok thanks, will see what we can do on our side, but a bunch of other things taking precedent at the moment.
Now that we have 2.9 released, I want to follow up on this.
I would like NATS to be able to interop with HomeAssistant. I do think that QoS2 is probably being misused a bit in this application. Not sure if there has been any movement on this from a hassagent perspective.
@derekcollison As far as I can tell, there's been no activity on the HASS.Agent side of things with regards to this issue.
ok, I thought the same when I looked.
We will get this implemented, like I said, would like NATS to be able to work with HomeAssistant for sure.
please assign me
@ariel-zilber I have assigned this to you as requested. Thank you for offering to help!
Great !! I am working on it
Any progress on this issue?
None at this point from Synadia side, we do plan on doing some improvements to MQTT layer in 2.10.
@robinsmidsrod I am curious if you were able to try out 2.10.x and had time to report back if Home Assistant works with nats now? I was planning on giving it a shot but it looks like there are still limitations. Thanks!
@onedr0p No, I have had no time to try this out. Honestly, after I figured out how to support both TLS and non-TLS (for my ESP8266 devices) in Mosquitto this hasn't had the same priority for me. I will probably revisit it sometime in the future, but you should try yourself and report back if it indeed works and what the current limitations are.
I'd like to add a CI test for compliance with Home Assistant. Can you please provide a few details on what software version, etc I should try it with? There appear to be multiple products on the homepage. CC @robinsmidsrod @onedr0p