open-coap / java-coap

CoAP Java library
Apache License 2.0
18 stars 5 forks source link

Notification without observe option #76

Open sbernard31 opened 6 months ago

sbernard31 commented 6 months ago

The RFC7641 - Observing Resources in the Constrained Application Protocol (CoAP) § 3.2. Notifications says :

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.

I think that currently java-coap doesn't allow this. Because when I try to send a 4.04 Not Found as notification, it is never sent.

I guess this is because of NotificationValidator, see :

https://github.com/open-coap/java-coap/blob/a0c8294df5a35d5f6a001f3fbc4ab85d95a89534/coap-core/src/main/java/com/mbed/coap/server/NotificationValidator.java#L24-L35

Not directly linked but that exception was silently ignore in my code (I mean I didn't even see a log), I don't know if there is something to improve in java-coap or in my code for this last point.

sbernard31 commented 6 months ago

I think there is more or less same issue at CoAP client side, see https://github.com/open-coap/java-coap/blob/a0c8294df5a35d5f6a001f3fbc4ab85d95a89534/coap-core/src/main/java/com/mbed/coap/server/messaging/CoapDispatcher.java#L65-L68

sbernard31 commented 4 months ago

any news about that ? :slightly_smiling_face:

szysas commented 4 months ago

Sorry, nothing yet, I did not have time to look into it.