Skip to content
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

Does deleting an object instance implicitly delete observations under the instance? #558

Closed
bryan-aetheros opened this issue Jan 27, 2023 · 4 comments

Comments

@bryan-aetheros
Copy link

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

@bryan-aetheros bryan-aetheros changed the title Does deleting an object instance implicitely delete observations under the instance? Does deleting an object instance implicitly delete observations under the instance? Jan 27, 2023
@sbernard31
Copy link

Hi,

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.

(Note that I'm not author of any those specifications LWM2M or CoAP)

@mkgillmore
Copy link

Group comments that if a client device removes an object or said instance, the device shall re-register with said servers and all observations shall be considered invalid. See lwm2m 1.2 "The Object Instance that is deleted in the LwM2M Client by the LwM2M Server MUST be an Object Instance that is announced by the LwM2M Client to the LwM2M Server using the "Register" and "Update" operations of the Client Registration Interface."

@mkgillmore
Copy link

See Section 6.3.7 Delete

@sbernard31
Copy link

The Object Instance that is deleted in the LwM2M Client by the LwM2M Server MUST be an Object Instance that is announced by the LwM2M Client to the LwM2M Server using the "Register" and "Update" operations of the Client Registration Interface."

A "Register" OR "Update" operation can be used to update supported Object/Instances.
Most of the time using a new "Register" in that case is overkill.
Common behavior is just to do an "Update".

if a client device removes an object or said instance, the device shall re-register with said servers and all observations shall be considered invalid

It could work but If lot of observe relation was established, this advice will lead to more traffic :

  • probably 1 new security handshake (depending on implementation and specification interpretation)
  • 1 register
  • 1 observe request for each observe relation previously established.

There is also some question about timing because here question was about remove than add again an instance.
So if you re-register after delete, then observation will not be done as new instance is not yet created. (unless you do the re-register after addition but that sounds more and more as a HACK because you will not register again each time you add a new instance)

My 2 cts, I will not go on that way. It sounds better to follow CoAP RFC and send a 4.0.4 not found to notify server that relation is not established anymore. then just do 1 or several "Update" to notify that instance is deleted/added then up to the server to decide if it want to reestablished the observe relation on update or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants