lwm2moma

Does deleting a LwM2M object instance implicitly delete observations under the instance?


The LwM2M spec does not specify what happens to an object instance's observations when a server deletes the object instance. For example, if a server has installed an observation on /5/0/3, then deletes /5/0 and subsequently creates a new /5/0, should the server assume that the observation on /5/0/3 no longer exists, and should be reinstalled?

Thanks, Bryan


Solution

  • The LWM2M observation feature is based on RFC7641 - Observing Resources in the Constrained Application Protocol (CoAP).

    Looking at RFC7641§3.2 Notifications, you can read :

    In the event that the resource changes in a way that would cause a normal GET request at that time to return a non-2.xx response (for example, when the resource is deleted), the server sends a notification with an appropriate response code (such as 4.04 Not Found) and removes the client's entry from the list of observers of the resource. Non-2.xx responses do not include an Observe Option.

    and at RFC7641§4.2 Notifications :

    A notification SHOULD have a 2.05 (Content) or 2.03 (Valid) response code. However, in the event that the state of a resource changes in a way that would cause a normal GET request at that time to return a non-2.xx response (for example, when the resource is deleted), the server SHOULD notify the client by sending a notification with an appropriate response code (such as 4.04 Not Found) and subsequently MUST remove the associated entry from the list of observers of the resource.

    (Note in LWM2M, the LWM2M client acts as a CoAP server and vice versa )

    So In a general way, I understand that if the object instance is deleted (for any reason), the LWM2M client (CoAP server) should send a 4.04 Not Found, then removes the observation relation. I guess LWM2M server (CoAP client) should also consider the relation is removed when he received a notification with a non-2.xx response code.

    For example, if a server has installed an observation on /5/0/3, then deletes /5/0 and subsequently creates a new /5/0, should the server assume that the observation on /5/0/3 no longer exists, and should be reinstalled?

    I understand it should reinstall.

    (I already answer to this at : https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues/558)