eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
722 stars 364 forks source link

My first notification was dropped #673

Closed JavaProgrammerLB closed 6 years ago

JavaProgrammerLB commented 6 years ago

My first notification was dropped

My Observe: observe

After My code run: now

Californium log: log

tcpdump packages: image

CoapClient coapClient = new CoapClient();
coapClient.setURI("http://*.*.*.*:5683/t/d");
coapClient.useCons();
coapClient.observe(new ObserveHandler());

I use: 2.0.0-M6

tcpdump cap file: devicebus-nbiot-access4.cap.zip

boaks commented 6 years ago

What is your client implementation?

The ACK (first response) contains a OBSERVE 0, response code 2.05 Content, but no payload !!!! The fist NON (MID: 7510) also contains OBSERVE 0, response code 2.05 Content, an payload
The second NON (MID: 7513) also contains OBSERVE 3, response code 2.05 Content, an payload

According https://tools.ietf.org/html/rfc7641#section-3.4, the first NON is not newer than the ACK. Therefore the NON is filtered out!

FMPOV, your client implementation is not proper working (I hope, it's not californium .-) ) It doesn't prepare the observe option of the ACK response proper not does it send the proper first payload in the response.

See also https://tools.ietf.org/html/rfc7641#appendix-A.1

The response to GET has observe 0 and payload, the next notification has observe 9 (and payload), and then 16 (and payload). So that observe option sequence will work. It takes the first payload from the response and then the payload of the following notifies.

JavaProgrammerLB commented 6 years ago

@boaks thanks for your answer,

boaks commented 6 years ago

What is your client implementation?

Sorry, I was wrong, the coap server implementation is important, it generates the suspicious ACK. If it is also californium 2.0.0-M6, I would appreciate, if you could provide some informations about the examples your using.

boaks commented 6 years ago

Can you give me some suggestion to fix the issue: ignore the ack, handle the notification

Fix the server to sent proper ACK responses, or really just a plain ACK. But this depends on your servers possibilities.

JavaProgrammerLB commented 6 years ago

@boaks thank you very much. The Observe server is run in our customer's IoT device, maybe implement in C.

JavaProgrammerLB commented 6 years ago

@boaks thank you a lot.

ObserveNotificationOrderer.java: image