-
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
General discussion / feedback from Leshan Team #27
Comments
Some answers
|
thx 🙏
|
|
Some more questions about observe. I think this will be one of the big part. o1. I find API to send the observe request but didn't find how to get notification (I guess I should use o2. Leshan server based on Californium is able to persists "Observation", so if the server reboots no need to resent a new Observe request to new handle notification. Do you think this is doable with java-coap ? (if yes, could you share some hint) |
I added a TokenGenerator to my experimentation, for now I go with a "not so java-coap" spirit way. (See eclipse-leshan/leshan@914f0d4). I guess it's OK for our POC. But just by curiosity, reading #24 (comment), I understand there is maybe a more elegant way to do with filter ? I try to investigate a bit but I'm not sure to find how I should add a filter to my client which I created like this I guess that I should customize I see there is an MIDSupplier but not a Token one. I also maybe find a typo in coap server should |
o1. To receive notifications, you could something like this:
Note that this sets separate callback per observation relation. o2. Currently that is not possible. How important is that feature for integration with Leshan? |
Related to TokenGenerator, yes, it would be more 'elegant' and testable to create a filter. However I noticed that there is a missing method in builder class to add addition filters. I will try to improve it. |
You're correct, thanks for pointing this out. |
o1. I will try to play with your example then I let you know if 1 observation consumer seems better to me. o2. It seems that users like observe feature but me not that much 😁 ... I try to rather encourage to use LWM2M Send Opeation which is a most simple alternative.
Maybe, it makes sense that some implementation support to persist observe relation and some others don't ? 🤔
For some use case this could be very important. Without going too deep in the details. I guess when you create a LWM2M server based on Leshan and you manage lot of clients in production with lot of Observe Relation. When you reboot your server, this will be an issue to resend all observe requests. (For sure at Sierra, we need it but at least at short/mid term we will still use Californium and Scandium for coap/coaps in production) |
I could not agree more with your finding about observe. Related to storing observation relations, it comes down not only to store Token->UriPath but also IP address... which is very fragile device association because those will change (NAT). |
Thats seems to confirm that implementers don't like so much "Observe" where users like it 😅
Ideally even more than a IP address, we find that to really make it work, it's better to store a kind of peer identify which are not the same depending of transport used or/and use cases. About o2) I just realize that I talk only about persisting observations but actually this is more than that... Let me know, if this is something you would "like" we explore together (first just by talking about it) or if you are too traumatized by "observe" feature 😁 |
In C201_CREATED(2, 01, 201),
- C202_DELETED(2, 02, 200),
+ C202_DELETED(2, 02, 202),
- C203_VALID(2, 03, 200),
+ C203_VALID(2, 03, 203),
- C204_CHANGED(2, 04, 200),
+ C204_CHANGED(2, 04, 204),
- C205_CONTENT(2, 05, 200),
+ C205_CONTENT(2, 05, 205), |
No, third parameter is HTTP status code. |
🤔 So I probably totally missed the purpose of this. Could you give me some hints ? 🙏 I was thinking this was just a way to get the code as |
Yes, it is used to translate (proxy) with HTTP |
I have a first working version of observe with java-coap at LWM2M server side. Without support of cluster, I don't need "single observation consumer" (more than that if you look at the code I think I could not implement if with 1 single observation consumer because too much information is missing in |
Please create separate ticket about observation consumer and let's discuss more there. For start, what context information would you need? |
Just to be sure this ticket should be about :
and ? or ?
|
About storing observation relations. |
This is done : #36 |
(After an huge refactoring in our integrations tests eclipse-leshan/leshan#1425 😫 which will allow to reuse most of our tests with java-coap, I'm back to work on this again) I'm currently using This is needed in LWM2M for Q option of Register operation. (see : LWM2M-v1.1.1@transport§Table: 6.4.3.-1 Operation to Method and URI Mapping (Registration Interface)) Just in case I double check if this is valid in CoAP, I think it is the RFC says :
(source : https://datatracker.ietf.org/doc/html/rfc7252#section-6.1)
(source : https://datatracker.ietf.org/doc/html/rfc7252#section-6.5) Let me know, if you want to adapt java-coap code and if I should create a dedicated issue. 🙂 |
Sounds like a missing feature so if you could create a separate ticket for this. That should not be too difficult to support. Thanks. |
For some integrations tests, I need to configure CoAP Timeout. // configure retransmission, with this configuration a request without ACK should timeout in
// ~200*5ms
configuration.set(CoapConfig.ACK_TIMEOUT, 200, TimeUnit.MILLISECONDS) //
.set(CoapConfig.ACK_INIT_RANDOM, 1f) //
.set(CoapConfig.ACK_TIMEOUT_SCALE, 1f) //
.set(CoapConfig.MAX_RETRANSMIT, 4); In CoapServer.builder().timeout(new CoapTimeout(ackTimeout, maxRetransmit)); But there is no way to change ACK_RANDOM_FACTOR which should be what replaces For now I fallback with If this is something you want to add, I can create a new issue. |
Adding parameter for ACK_RANDOM_FACTOR should be trivial thing to do, so if it helps you, please create a separate ticket. By the way, there was API change on how to set retransmission strategy (it was inspired by one of our discussion in this area). Now it is for example:
|
Not really a feature request but just a user feedback about
Some of this setters are grouped as Modifiers does not modify the instance but create (clone) a new Maybe there are good reason to do that but from a user point of view, I think this is a bit missleading. My first try with the API looks like this and it took me some time to find that some 'setter' returns new instances. // Create CoAP request from LWM2M Read Request
coapRequest = CoapRequest.get(getAddress(), getURI(request.getPath()));
coapRequest.token(tokenGenerator.createToken()); // this is the missleading part.
if (request.getContentFormat() != null)
coapRequest.options().setAccept(request.getContentFormat().getCode()); |
I didn't find the way to get token on I also see there is a way to get PeerAddress on |
When we handle a message (mainly a request) is there a way to know local address ( |
I agree, it is misleading. The idea is to have immutable CoapRequest and CoapResponse, so that if it's modified down the pipeline, there is no surprises. Currently header options are not immutable so that is one problem. Maybe one solution would be to have dedicated builder class for CoapRequest and CoapResponse. |
Yes, there is no API to get token from coap-response. Observation are wrapped around SeparateResponse class will provide those metadata. |
No, there is no such an API. What's the use case behind it? |
It makes sense.
Yes, when I run into this kind of problem, I usually end up using a builder. (Even if I feel that the builder also has drawbacks but I haven't found a better solution). |
I'm not sure I get you. Are you saying that I can get an instance of SeparateResponse when I handle notification ? I share that, just in case that you think this should be obviously added. |
I suspected that you were going to ask the question 🙂 because that sounds like a strange feature request. This is not strictly needed but this could make my code a bit simple. (so no urgency to take a decision about this)
Here is the trick I used because of wildcard port :
(Not sure this is so clear 😬 ) |
One way of passing such information would be through TransportContext, we could put it there and then each received message will contain it, for example: In
Note that SERVER_SOCKET is a context key, and could be defined like:
Still it is worth to note that currently, CoapServer does not support reading/writing from/to multiple sockets... so I'm not sure if my above suggestion will be of any help. |
Yep I get it, I think this could help even if multiple sockets in not supported. This way I could remove the |
Maybe you missed (#27 (comment)) ? Any opinions about it ? |
I didn't look too much (so sorry if there is obvious API) :
|
This use case is currently not supported : RouterService.RouteBuilder routerBuilder = new RouterService.RouteBuilder();
routerBuilder //
.any("/", new RootResource() //
.any("/myResource", new MyResource() //
.any("/*", new Default());
router = routerBuilder.build(); Do you think it make sense to support it ? |
For that, my suggestion from comment: #27 (comment) will solve the issue. So server bind address will be passed in CoapRequest's transport context. |
That's not obvious at all. Best it to look into
No
No |
Yes, it make sense.. I'm surprise that currently this does not work. |
I think there is maybe a confusion because I was not asking about bind address but about getting Token on CoapResponse/Notificaiton thread. I guess mixing several thread of discussion in same issue could easily lead to this kind of confusion 🙂 . |
Should I create issue to discuss about : ? |
Some wording: I call Some context: I started to try to implement observe at LWM2M client side (CoAP server side) I try something base on code you shared previously. (#27 (comment)) Here is a little description about how I implement it for now. (If you have better idea I take it) my problems/questions : o1) I would like to remove the observe relation when is it removed in java-coap stack. (E.g. on passive cancel). Is there a way to do that ? Maybe I didn't use the right design ? |
Hi, there is a major refactoring coming related to observation handling (inbound and outbound). It is mainly related to this issue: #36, and it should simplify use case that you have described. |
Just give you some news about java-coap integration in Leshan. I get something that I consider as testable/usable with :
(I plan to integrate it in There is still some issues or point which could be improved, I will take time to report it later. (If you can not wait 😅, you can have a look at the code, there is some TODO ) My next step will be to try to provide a Out of topic question, I see in
What is used for DTLS in that case ? I understood that DTLS support is only provided by mbedtls. |
Great 🤞 Yes, for DTLS there is only integration done with mbedtls. Main reason is the support of DTLS with CID. |
AFAIK, the only pure java DTLS 1.2 implementation which support CID is Scandium from Californium project. (So with same problem than Californium to me) I also understood that there is a DTLS implementaiton in JDK (probably without CID support), did you test it ? Do you know if DTLS 1.3 is usable with your mbedtls binding ? Common issue about using native binding in Java is when application crash or when debugging is needed. Did you face this kind of issue with mbedtls binding ? Sometime I tell myself that Java world need an open source project dedicated to a pure Java DTLS implementation. 🤔 |
Yes, there is DTLS in JDK but without CID and is not obvious how to use it. |
Summary :
Leshan is a java implementation of LWM2M and until now it was strictly based on californium.
Recently we did massive changes to abstract transport Layer. (See : eclipse-leshan/leshan#1025)
Now to test this abstraction we are playing with java-coap (See : eclipse-leshan/leshan#1373)
I will use this general issue to ask questions and provides feedback about it.
Some questions :
In californium, there is a endpoint concept. If I simplify the concept a lot this is the socket where message are received. In californium a coap server can have several endpoints. If I understand java-coap correctly, 1 server is only associated to 1 socket right ?
is there a way to check if a message (request or response) is CON or not ? something like :
if (!CON.equals(coapRequest.getType()))
is there a way to set a message (request or response) as CON ? something like :
coapRequest.setConfirmable(true);
is there a way to execute code after the message( mainly needed for response) is sent ? Maybe a callback once the message is sent ?
Patch, IPatch and Fetch seems not implemented ? correct ? is it planned to implement it ? (I think we mainly need Ipatch and fetch for lwm2m composite operation)
If you are curious you can have a look at how we are using java-coap, See : https://github.com/eclipse/leshan/compare/5b0b66fa675da2ad9224d15e828036d0c06d0f40
E.g : I created a kind of ResourceService to be able to add some Resource (see RegistrationResource), I don't know if this is a good idea or if this could give you some hint about changing
java-coap
API ? 🤷♂️(more question is coming soon 😁 )
The text was updated successfully, but these errors were encountered: