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

Notification without observe option #76

Open
sbernard31 opened this issue Dec 8, 2023 · 3 comments
Open

Notification without observe option #76

sbernard31 opened this issue Dec 8, 2023 · 3 comments

Comments

@sbernard31
Copy link
Collaborator

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.

@sbernard31
Copy link
Collaborator Author

I think there is more or less same issue at CoAP client side, see

} else if (packet.isSeparateResponse() && packet.headers().getObserve() != null) {
handleObservation(packet);
return;
}

@sbernard31
Copy link
Collaborator Author

any news about that ? 🙂

@szysas
Copy link
Collaborator

szysas commented Mar 4, 2024

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

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

2 participants