oasis-tcs / mqtt

OASIS MQTT TC: Technical refinements of features
Other
4 stars 2 forks source link

MQTT-612 Publish does not allow topic registration #12

Closed icraggs closed 5 months ago

icraggs commented 7 months ago

https://issues.oasis-open.org/browse/MQTT-612

When using subscribe, an implicit registration of a topic alias is done (if the topic filter contains no wildcards). This is not done for publish, where a REGISTER must be used beforehand.

In MQTT 5, topic alias registration is done with a publish. If we allow topic registration on a publish (not QoS -1), we will be aligning with MQTT 5, and reducing the need for using REGISTER/REGACK exchanges.

Note that MQTT 5 states:

The Topic Alias mappings used by the Client and Server are independent from each other. Thus, when a Client sends a PUBLISH containing a Topic Alias value of 1 to a Server and the Server sends a PUBLISH with a Topic Alias value of 1 to that Client they will in general be referring to different Topics.

I believe we should adopt the same approach in MQTT-SN (it's not clear from the 1.2 specification). That would mean changing the PUBLISH packet to always include both topic alias and topic length fields, using them in the same manner as MQTT 5. Specifically this:

_The sender decides whether to use a Topic Alias and chooses the value. It sets a Topic Alias mapping by including a non-zero length Topic Name and a Topic Alias in the PUBLISH packet. The receiver processes the PUBLISH as normal but also sets the specified Topic Alias mapping to this Topic Name.

If a Topic Alias mapping has been set at the receiver, a sender can send a PUBLISH packet that contains that Topic Alias and a zero length Topic Name. The receiver then treats the incoming PUBLISH as if it had contained the Topic Name of the Topic Alias._

icraggs commented 7 months ago

Davide:

For all PUBLISH packets

_"a sender can send a PUBLISH packet that contains that Topic Alias and a zero length Topic Name"_
    In the PUBLISH packets it is never required to send a zero length Topic Name, right? In fact Topic Length and Topic Alias are alternative fields, right?

For PUBLISH-1 and PUBLISH OUT OF SESSION packets:

_"The receiver processes the PUBLISH as normal but also sets the specified Topic Alias mapping to this Topic Name."
    How it possible is the session has not been established?_ 
icraggs commented 7 months ago

Ian Craggs:

  1. yes the topic length and alias are at the moment alternative fields, they would have to become both present. I would say that could simplify the publish packet, albeit make it two bytes longer.
  2. this would not apply to QoS -1 (out of session) publishes (I did mention that in the description, but perhaps didn't highlight it enough)
icraggs commented 7 months ago

We had a discussion in the workshop on the 19th and agreed to keep the behavior the same as 1.2 where the Gateway is the keeper of the topic aliases.

icraggs commented 5 months ago

Tracking in Jira again.

sthagen commented 4 months ago

At https://issues.oasis-open.org/browse/MQTT-612