-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feedback about new API for CoAP Observe. #56
Comments
There is no nightly builds, only option would be to build locally. |
Created a PR: #57 |
About naming, I take a look at RFC7641 to check wording used. At client side, they often talks about "Observation", e.g :
So I guess At server side, they often talks about "Observer", e.g :
So maybe for Just to let you know, in Californium, naming are :
|
About So I understand that each time one resource of my CoAP resources tree is modified, I need to generate a CoapResponse to pass to If I'm correct, I think there is a little issue with this design, ideally a There is maybe another issue with following use case : |
Thanks @sbernard31, You have really good points about naming, I will do changes:
The idea behind passing
I'm aware of this limitation, which was also before changes we are discussing. I would suggest to take it as separate issue. |
Yep I understand.
Exactly, I can imagine use case where resource tree change a lot and if each modification means encoding in complex content format (like SenML-JSON or CBOR), this will not be so good. And I'm afraid this will not be compatible with other issue, I reported.
Maybe we can even replace it by a This solution could also solve the other issue I reported
We can do that but I'm afraid that I mixed both problem 😁 just above. |
That is a neat idea, I like it :) |
Note, I updated branch with above changes (https://github.com/open-coap/java-coap/tree/observation-handlers#coap-client-complete-usage) |
Still about But I ask myself if we should also add a way to have a custom way to select the observer instead of just select by URI. I try to explain my use case : Now a concrete example :
Now Imagine that I observe resources below :
With current design, I need to translate :
in
And call An idea would be to propose another method with custom Filter/Selector : sendNotification(
Predicate<CoapRequest /* I'm not sure if CoapRequest is the right input */> ObserverFilter,
Service<CoapRequest, CoapResponse> responseProvider) Let me know if It is not clear enough. |
Maybe instead of |
Good point and good idea. |
@sbernard31 let me know if you have any more suggestions, if not I would like to merge this #57. Maybe it would be easier for you to test a released version. |
@szysas, I'm currently testing the client side and first tests sounds good (but guess what I'm a gradle noob 😅) Is it OK for you to wait ? or that was a problem to not be able to merge now ? |
That is perfectly fine to wait. |
I adapted my code to new API. If you are curious about what it could looks like : This is clearly better. At client side : There was a long discussion about that long time ago at Californium repository : eclipse-californium/californium#500. (That was so long time ago that I didn't remember everything about this 😅 ) For now, I don't know what could be the best move. I share this just to let you know. At Server side: Current code does not support that ☝️ , I think I will also need Let me know if you need more clarification for this 2 points ☝️ |
Overwrite?
I see your point but I am not really sure how changing into One way to handle composite observation would be to create Filter like:
Then compose it with
|
Yep, ideally the observation should be identified by "device identity + token". But currently (for californium historical reason), Leshan are using token only. Anyway, the point is more that It's hard to be sure that Token used for "observe request" will not be already used when Even if, I check if token is not already used (at cost of 1 more call to shared stored) when I generate it, I can not be sure it will not be used at "add" time. (e.g. because of race condition) I just let you know the problem, just in case, you have an idea to handle it. |
Stupid idea but what if you simply make a counter and increment each time subscription is send? With this approach you have extremely small chances that token is reused (hard to believe that there will be 281 474 976 710 655 subscriptions) |
About Maybe I don't get you but I think it will not work. 🤔
About FETCH, the RFC8132§1.1. FETCH says :
So I feel that using URI as main identifier in
The idea is to implement something like this : But for Observe Composite it will looks like : /** Called when resources changed */
public void resourceChanged(LwM2mPath... paths) {
// send notification if there is observers for it
observersManager.sendObservation((coapRequest) -> {
List<LwM2mPath> listOfResourceObservedByCompositeObserve = getPaths(coapRequest);
if (listOfResourceObservedByCompositeObserve != null) {
for (LwM2mPath observePath : listOfResourceObservedByCompositeObserve) {
for (LwM2mPath path : paths) {
if (path.startWith(observePath)) {
return true;
}
}
}
}
}, responseProvider);
/** get LWM2M path to observe from coap request
public List<LwM2mPath> getPaths(CoapRequest coapRequest) {
// here I can decode payload which contains LWM2M path for each call
// but ideally I would prefer to be able to decode it once and then attach it to the request.
} |
Thx for the idea 🙏 , maybe this is way to explore 🤔 |
About composite observe:
Then, when doing usual:
Works the same as with "normal" subscriptions. Another alternative is to implement own |
Looking at your previous comment and also code your share, it seems to me there is 2 points about Observe with FETCH we don't understand in a same way. I think this is important that we agree on this (or at least agree on disagreement 😅) before to enter in implementation discussion 🙂 So let's focus on CoAP only (ignoring LWM2M for now).
Let me know, if there is points you disagree with 🙂 |
In RFC8132 there is very little about observe with FETCH:
How I see it, is that there is no difference when subscribing with GET or FETCH. With GET, you can subscribe for different content type ( |
So let's try to clarify point 2. together.
I agree that accept + payload is needed to create the "notification". Still with RFC8132§2.7. A Simple Example for FETCH, you can observe :
and also :
Both observation relation target
I let aside implementation question for now. |
OK, I see your point, so in addition to different notifications content, we might have no notification at all. Agree with you on this ;) |
Ok so I think we can go back to code discussion. 🙂 I understand the
I think the main missing point is 2, that's why I proposed the |
Uff ;) Adding
And here we are entering area that is becoming more LwM2M specific. So maybe implementing |
Yep, I understand the concern. Note that this is also true for
I disagree, I think often when you will use FETCH you will have information in the payload which need to be decoded.
Yep this is clearly an option but I feel too bad that we don't find something at Anyway thanks for this constructive discussion, this helps me to clarify my mind about all of this. 🙏 |
Well, there will less subscribed uri-paths, and comparing just Strings is a lot easier.. but that just optimisation.
👍 |
Here is my first try : eclipse-leshan/leshan@2739377 This is a draft. The store allows :
We still have the "iterate over all observers issue" but I don't know if this is a real issue or if fixing it will be a premature optimization but If you want me to try to find a solution for it, I can try. Let me know, what you think about that and if we should go deeper in that way. |
@sbernard31 |
No urgency on my side, I have a working solution to move forward. 🌴 Enjoy your vacation 😉 |
Hi @sbernard31 , should we come back to this discussion after long break? I still have a concert if using ObserverManager for composite observations is a right way forward for now, but in general observation mechanism from CoAP and LwM2M is not the simplest and so I'm probably missing the point. Is the |
Just came back.
I understand.
Yep let's do that. |
This issue will be used to discuss / provide feedback of new API for CoAP Observe.
This was triggered by #27 (comment) :
I have regularly same naming problem with Leshan 😅
@szysas if I want to test that version ☝️. What is the recommended way ?
The text was updated successfully, but these errors were encountered: