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

Problem with registration of some LwM2M clients after upgrading to leshan-2.0.0-M7 #1273

Closed
JaroslawLegierski opened this issue Jun 27, 2022 · 5 comments
Labels
question Any question about leshan

Comments

@JaroslawLegierski
Copy link
Contributor

JaroslawLegierski commented Jun 27, 2022

We noticed that after upgrading to leshan-2.0.0-M7, some devices stopped successfully registering in leshan server. We are observing following error:

[DEBUG] Invalid request [CON-POST   MID=50791, Token=150001, OptionSet={"Uri-Path":"rd", "Content-Format":"application/link-format", "Uri-Query":["lt=86400","lwm2m=1.1","ep=leshan100"]}, "</1/0>;ver=1.1,</3/0>;ver=1.1"] received on the resource /rd from Identity /78.8.63.187:60815[psk=leshan100]
org.eclipse.leshan.core.link.LinkParseException: Unable to parse link 	
        at org.eclipse.leshan.core.link.lwm2m.DefaultLwM2mLinkParser.parseCoreLinkFormat(DefaultLwM2mLinkParser.java:155)
        at org.eclipse.leshan.server.californium.registration.RegisterResource.handleRegister(RegisterResource.java:146)
        at org.eclipse.leshan.server.californium.registration.RegisterResource.handlePOST(RegisterResource.java:104)
        at org.eclipse.californium.core.CoapResource.handleRequest(CoapResource.java:246)
        at org.eclipse.leshan.core.californium.LwM2mCoapResource.handleRequest(LwM2mCoapResource.java:51)
        at org.eclipse.californium.core.server.ServerMessageDeliverer.deliverRequest(ServerMessageDeliverer.java:106)
        at org.eclipse.californium.core.network.stack.BaseCoapStack$StackTopAdapter.receiveRequest(BaseCoapStack.java:218)
        at org.eclipse.californium.core.network.stack.AbstractLayer.receiveRequest(AbstractLayer.java:84)
        at org.eclipse.californium.core.network.stack.AbstractLayer.receiveRequest(AbstractLayer.java:84)
        at org.eclipse.californium.core.network.stack.BlockwiseLayer.receiveRequest(BlockwiseLayer.java:562)
        at org.eclipse.californium.core.network.stack.ReliabilityLayer.receiveRequest(ReliabilityLayer.java:296)
        at org.eclipse.californium.core.network.stack.AbstractLayer.receiveRequest(AbstractLayer.java:84)
        at org.eclipse.californium.core.network.stack.BaseCoapStack.receiveRequest(BaseCoapStack.java:140)
        at org.eclipse.californium.core.network.CoapEndpoint$1.receiveRequest(CoapEndpoint.java:302)
        at org.eclipse.californium.core.network.UdpMatcher$2.run(UdpMatcher.java:289)
        at org.eclipse.californium.elements.util.SerialExecutor$1.run(SerialExecutor.java:290)
        at org.eclipse.californium.core.network.CoapEndpoint$6.run(CoapEndpoint.java:1341)
        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)
Caused by: java.util.UnknownFormatConversionException: Conversion = '%'
        at java.base/java.util.Formatter.checkText(Formatter.java:2732)
        at java.base/java.util.Formatter.parse(Formatter.java:2718)
        at java.base/java.util.Formatter.format(Formatter.java:2655)
        at java.base/java.util.Formatter.format(Formatter.java:2609)
        at java.base/java.lang.String.format(String.java:2897)
        at org.eclipse.leshan.core.link.lwm2m.attributes.LwM2mAttributeModel.getApplicabilityError(LwM2mAttributeModel.java:98)
        at org.eclipse.leshan.core.link.lwm2m.attributes.MixedLwM2mAttributeSet.validate(MixedLwM2mAttributeSet.java:97)
        at org.eclipse.leshan.core.link.lwm2m.DefaultLwM2mLinkParser.parseCoreLinkFormat(DefaultLwM2mLinkParser.java:149)
        ... 19 common frames omitted

It seems that the "Object Version" attribute is attached to an object instance (e.g. /1/0) when it is only allowed for the object.
We know that this behavior is not fully consistent with the LwM2M standard but maybe we should allow such devices to register in the Leshan server ?

@sbernard31 sbernard31 added the question Any question about leshan label Jun 27, 2022
@sbernard31
Copy link
Contributor

sbernard31 commented Jun 27, 2022

It seems that the "Object Version" attribute is attached to an object instance (e.g. /1/0) when it is only allowed for the object.
We know that this behavior is not fully consistent with the LwM2M standard

Yep the LWM2M spec v1.1 and v1.0 are clear about that :

See :

we should allow such devices to register in the Leshan server ?

This is a general question about how Leshan should handle device which doesn't strictly respect the specification.

As I said at #1270 (comment)
_"Why be strict by default, In a general way I try to explain this at (#1103 (comment) (see answer to ""how should we do that ?"")

So the short idea, trying to be strict by default, but let user make their own server less strict if needed.
I should really take time to create wiki page about this.

In your case you can create your own Parser :

// define your supported attributes 
Collection<AttributeModel<?>> supportedAttributes = new ArrayList<AttributeModel<?>>();
supportedAttributes.addAll(Attributes.ALL);
supportedAttributes.addAll(LwM2mAttributes.ALL);

// change the object_version one
supportedAttributes.remove(LwM2mAttributes.OBJECT_VERSION);
// create your custom model which support to assign OBJECT_VERSION To OBJECT and OBJECT_INSTANCE level instance.
supportedAttributes.add(new YourObjectVersionAttributeModel());

// add the new LinkParser
builder.setLinkParser(new DefaultLwM2mLinkParser(supportedAttributes));

Caused by: java.util.UnknownFormatConversionException: Conversion = '%'

This is a bug you should get a message like :

ver attribute is only applicable to [Object], and so can not be assigned to OBJECT_INSTANCE"

This is fixed in master.

@davidahoward
Copy link

davidahoward commented Sep 28, 2022

I saw a similar problem:

#1315 However, after looking at the specification I closed my ticket even though the V1.1 and V1.2 specification contradict each other on this topic with examples.

https://www.openmobilealliance.org/release/LightweightM2M/V1_2-20201110-A/HTML-Version/OMA-TS-LightweightM2M_Core-V1_2-20201110-A.html#7-2-3-0-723-Object-Definition-and-Object-Version-Usage

7.2.3. Object Definition and Object Version Usage
An LwM2M Client supporting LwM2M Enabler version 1.0 registers this Object in version 2.2 along with the Server Object version 1.0 ("urn:oma:lwm2m:oma:1"), and the Device Object version 1.0 ("urn:oma:lwm2m:oma:3"). The registration payload is:

</1/0>,</1/1>,</3/0>,</44/0>;ver=2.2

It seems this is an area that will need clarification in upcoming specifications.

For now, however, it would be helpful if leshan allowed the more compact format ...

There is discussion in the OMA DSME group that would codify the following behavior:

</44>;ver=2.2, </44/0>,</44/1> is OK.
</44>;ver=2.2 is OK (when there are instances of the Object 44).
</44/0>;ver=2.2 is OK.
But </44/0>;ver=2.2,</44/1>;ver=1.9 is not allowed.

@sbernard31
Copy link
Contributor

I answer to that at : #1315 (comment)

@sbernard31
Copy link
Contributor

There is discussion in the OMA DSME group that would codify the following behavior

As I said at #1315 (comment), my bet this will not affect LWM2M v1.0 or LWM2M v1.1. So I think we can close this issue ?

@JaroslawLegierski
Copy link
Contributor Author

Yes it's a good idea. Thanks for explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Any question about leshan
Projects
None yet
Development

No branches or pull requests

3 participants