OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

mqtt-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: Lifetime of topic alias map


On Fri, Aug 14, 2020 at 1:53 PM Takatoshi Kondo <redboltz@gmail.com> wrote:
>
> Hi,
>
> I have a question about the lifetime of TopicAlias map.
>
> According to https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Topic_Alias
>
> > Topic Alias mappings exist only within a Network Connection and last only for the lifetime of that Network Connection.
>
> It seems that the lifetime of the map is over when the network
> connection is closed.
>
> Consider the following scenario.
>
> 1. Client connects to the broker with CleanStart: false
> SessionExpiryInterval=0xfffffffff(infinity)
> 2. Client publishes topic1 with TopicAlias: 1, QoS: 1, PacketId: 1
>    Broker inserts topic1 - ToppicAlias 1 entry to the map.
> 3. Client publishes empty topic  with TopicAlias: 1, QoS: 1, PacketId: 2
>    Broker finds topic1 from the map using TopicAlias 1 as the key.
> 4. Client receives PUBACK PacketId: 1.
> 5. Disconnect between the client and the broker. Broker clears the map here.
> 6. Client connects to the broker with CleanStart: false
> SessionExpiryInterval=0xfffffffff(infinity)
> 7. Client publishes empty topic  with TopicAlias: 1, QoS: 1, PacketId:
> 2 (PUBACK PacketId: 2 is not received so resend step 3 message)
> 8. Broker can't find the topic corresponding to the TopicAlias: 1 in
> the map because the map has been cleared at the step 5.
>    What should happen here? Should the broker disconnect the client
> due to no matching TopicAlias with empty TopicName ?

According to the spec,  DISCONNECT with Reason Code of 0x82 (Protocol
Error) should happen.

See

---
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901120

3)    If the receiver does not already have a mapping for this Topic Alias
a)    If the packet has a zero length Topic Name field it is a
Protocol Error and the receiver uses DISCONNECT with Reason Code of
0x82 (Protocol Error) as described in section 4.13.
---

That indicates that re-send and disconnect happen again and again if
Topic Alias map lifetime lasts only for the lifetime of that Network
Connection.
If Topic Alias map lifetime lasts the same as session lifetime, the
re-send won't cause DISCONNECT.

---
Thanks,
Takatoshi

>
> If the client continues to re-connect with the same parameter, the
> publish packet at the step 3 is never processed by the broker.
> The client needs to set CleanStart: true to erase re-send publish
> message. But it avoids message deliverty guarantee.
>
> I think that if the lifetime of the map is the same as session
> lifetime, it is easy to use.
> At the step 5, broker dossn't clear the map. The lifetime of the map
> is extended until the session lifetime is over.
>
> However, session is defined as follows:
>
> https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc473619931
>
> > A stateful interaction between a Client and a Server. Some Sessions last only as long as the Network Connection, others can span multiple consecutive Network Connections between a Client and a Server.
>
> It seems ttat Network Connection and session are different concept.
>
> I think that TopicAlias mapping should have the same lifetime as the
> session lifetime.
>
> Any ideas?
>
> ----
> Thanks,
> Takatoshi


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]