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 with Error Code are not supported #1560

Open
sbernard31 opened this issue Dec 8, 2023 · 3 comments · Fixed by #1561
Open

Notification with Error Code are not supported #1560

sbernard31 opened this issue Dec 8, 2023 · 3 comments · Fixed by #1561
Labels
bug Dysfunctionnal behavior server Impact LWM2M server

Comments

@sbernard31
Copy link
Contributor

Playing leshan-server-demo, I faced :

[WARN] Unable to handle notification of [Hu6ujaOuLP:/3442/0/1110/0]  
org.eclipse.leshan.core.request.exception.InvalidResponseException: Unexpected response code [4.04] for SingleObservation [path=/3442/0/1110/0, id=Ox656143955aec5b23, contentFormat=SENML_JSON(110), registrationId=Hu6ujaOuLP, context={}]
	at org.eclipse.leshan.server.californium.endpoint.ServerCoapMessageTranslator.createObservation(ServerCoapMessageTranslator.java:92)
	at org.eclipse.leshan.server.californium.endpoint.CaliforniumServerEndpointsProvider$2.onNotification(CaliforniumServerEndpointsProvider.java:168)
	at org.eclipse.californium.core.network.CoapEndpoint$NotificationDispatcher.onNotification(CoapEndpoint.java:811)
	at org.eclipse.californium.core.network.BaseMatcher$2.onResponse(BaseMatcher.java:250)
	at org.eclipse.californium.core.coap.Request.setResponse(Request.java:916)
	at org.eclipse.californium.core.server.ServerMessageDeliverer.deliverResponse(ServerMessageDeliverer.java:280)
	at org.eclipse.californium.core.network.stack.BaseCoapStack$StackTopAdapter.receiveResponse(BaseCoapStack.java:214)
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:89)
	at org.eclipse.californium.oscore.ObjectSecurityContextLayer.receiveResponse(ObjectSecurityContextLayer.java:274)
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:89)
	at org.eclipse.californium.core.network.stack.ExchangeCleanupLayer.receiveResponse(ExchangeCleanupLayer.java:105)
	at org.eclipse.californium.core.network.stack.ObserveLayer.receiveResponse(ObserveLayer.java:154)
	at org.eclipse.californium.core.network.stack.BlockwiseLayer.receiveResponse(BlockwiseLayer.java:862)
	at org.eclipse.californium.core.network.stack.ReliabilityLayer.receiveResponse(ReliabilityLayer.java:308)
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:89)
	at org.eclipse.californium.oscore.ObjectSecurityLayer.receiveResponse(ObjectSecurityLayer.java:394)
	at org.eclipse.californium.core.network.stack.AbstractLayer.receiveResponse(AbstractLayer.java:89)
	at org.eclipse.californium.core.network.stack.BaseCoapStack.receiveResponse(BaseCoapStack.java:132)
	at org.eclipse.californium.core.network.CoapEndpoint$1.receiveResponse(CoapEndpoint.java:324)
	at org.eclipse.californium.core.network.UdpMatcher$4.run(UdpMatcher.java:457)
	at org.eclipse.californium.elements.util.SerialExecutor$1.run(SerialExecutor.java:292)
	at org.eclipse.californium.core.network.CoapEndpoint$6.run(CoapEndpoint.java:1367)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

This happens when an observed node is removed. In that case a last NOT_FOUND notification should be sent.

See 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.

@sbernard31
Copy link
Contributor Author

This should fix for Californium endpoint : #1561

But unfortunately, this can not be fix for java-coap yet, see open-coap/java-coap#76

@sbernard31
Copy link
Contributor Author

sbernard31 commented Dec 8, 2023

I put this log code that I may need again when I will work on java-coap provider
server.getObservationService().addListener(new ObservationListener() {

    @Override
    public void onResponse(CompositeObservation observation, Registration registration,
            ObserveCompositeResponse response) {
        System.out.println("==================");
        System.out.println("RESPONSE " + response);
        System.out.println("==================");
    }

    @Override
    public void onResponse(SingleObservation observation, Registration registration, ObserveResponse response) {
        System.out.println("==================");
        System.out.println("SINGLE RESPONSE " + response);
        System.out.println("==================");

    }

    @Override
    public void onError(Observation observation, Registration registration, Exception error) {
        System.out.println("==================");
        System.out.println("ERROR " + error);
        error.printStackTrace();
        System.out.println("==================");

    }

    @Override
    public void newObservation(Observation observation, Registration registration) {
        System.out.println("==================");
        System.out.println("NEW OBS " + observation.getId());
        System.out.println("==================");

    }

    @Override
    public void cancelled(Observation observation) {
        System.out.println("==================");
        System.out.println("CANCELLED " + observation.getId());
        System.out.println("==================");

    }
});

@sbernard31
Copy link
Contributor Author

Issue was closed automatically because I integrated #1561 in master but this only fixes the Californium provider.

Bug for java-coap is still there so I reopen.

@sbernard31 sbernard31 reopened this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Dysfunctionnal behavior server Impact LWM2M server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant