-
Notifications
You must be signed in to change notification settings - Fork 9
Description
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 :
java-coap/coap-core/src/main/java/com/mbed/coap/server/NotificationValidator.java
Lines 24 to 35 in a0c8294
| class NotificationValidator implements Filter.SimpleFilter<SeparateResponse, Boolean> { | |
| @Override | |
| public CompletableFuture<Boolean> apply(SeparateResponse obs, Service<SeparateResponse, Boolean> service) { | |
| if (obs.options().getObserve() == null) { | |
| throw new IllegalArgumentException("Notification packet should have observation header set"); | |
| } | |
| if (obs.getToken().isEmpty()) { | |
| throw new IllegalArgumentException("Notification packet should have non-empty token"); | |
| } | |
| return service.apply(obs); | |
| } |
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.