Skip to content

Notification without observe option  #76

Description

@sbernard31

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 :

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions