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
LwM2mNodeSenMLDecoder sometimes fails trying to convert from double to long #1170
Comments
Are you using senml-json or senml-cbor ? |
could you share the exact payload (byte for cbor / string for json) sent by the client ? |
Hmm, I don't set a specific ContentFormat in ReadRequest, so I'm not sure which one is used by default. Note: I only 4 devices for development/testing, we're not in production yet. |
You can put in the ReadRequest the format you would like to be used for the response. Eg. :
See in my example : |
Just speculation,
It seems at some point we get a double (a floating point number) in Leshan where we expect a long (an integer). My guess is when the timestamp ends with several 0, your client will use the exponential format. I also guess our json library (jackson) convert a timestamp like Why sometime it works ? because when timestamp does ends with many 0 maybe you client use the "normal notation" like Anyway, this is too many guess and I would like to be sure so I wait for more input from you. |
Any news about this ? I'm really curious to know what happens as maybe we should be more flexible here. 🤔 |
Not yet. I tried to record the messages using Wireshark during the night to catch this error but system crashed somewhere at midnight due to a lack of memory.. |
Content format is "Content-Format":"application/senml+json". |
OK so I will try to test how Leshan behave with JSON number exponential notation. |
I'm able to reproduce it : #1174. I will try to add a safe conversion in NumberUtils. |
Great, thanks. |
This is not yet available in |
I'm using senml-cbor now. In order to test this properly I would have to let it run for at least one day, but we are solving some other issues now, so I'm not sure when I'll be able to do it. Please, don't wait with the merge (regarding the fact hat you are able to reproduce this issue in a unit test). In any case, I'll do some more testing when I'll have time and I'll also test using senml-json. BR |
Sure. In the first version we will not use Leshan cluster (not sure if it's really needed as the number of devices is not that big). |
hi, Now we found a similar problem using SENM_CBOR: Can not convert 3000.0 to long safely [CoapServer(main)#6] ERROR c.n.s.d.s.s.d.ModuleManagerImpl - Endpoint 94193A04070000EA: Read request for path 3 failed with exception: {} |
#1174 should fix this kind of problem for senML+cbor too. Which version are you using ? Note that : even if I add this more flexible behavior which tolerates to convert Double in Long safely. For JSON, there is no clear way to know the type of a number.
For CBOR, I feel this is even more wrong as the LWM2M specify that integer representation must be used for integer. Reading the specification again, I'm wondering if Leshan should tolerate this by default for senml+cbor. I feel it should not. (and so I will maybe change this again) |
We don't use your fix yet. |
I create an issue about this : #1176 |
I contacted the manufacturer regarding the senml-cbor decoding issue. Their comment: "Regardless of BigNum being Integer, it is set as float." |
I think their are wrong. 🤔
|
Hi, I'm attaching Wireshark captures for both senml+json and senml+cbor (I'm sorry it took so long). If I read these captures correctly I see that also if I set content format in request to senml+cbor, I'm getting senml+json response.. |
About the float number SenML-JSON issue : Not related to this issue but looking your capture, I feel there is maybe some issue at client side : 1) too many answer about DTLS retransmission ?
There is a lot of retransmission because it seems that device takes long time too answer. (1 request + 3 retransmission) 2) request where senml-cbor is asked and senml-json is returned
And
(Table: 6.7.-3 Response Codes: Device Management and Service Enablement Interface) So either the device should return payload using senml+cbor or it should return 4.06 error. |
Example of misleading about this #1170 (comment)
Thank you. |
Thx again for taking time to reporting this. That's help a lot 🙏 |
Hi,
We are using Leshan 2.0.0-M5.
In the log files I sometimes see that when reading currentTime resource from device object (3/0/13) decoding sometimes fails with the following exception:
08:50:47 [CoapServer(main)#27] ERROR c.n.s.d.s.s.d.ManagerImpl - Endpoint 94193A0407000000: Read request for path 3 failed with exception: {}
org.eclipse.leshan.core.request.exception.InvalidResponseException: Unable to decode response payload of request [ReadRequest [path=/3 format=null]] from client [94193A0407000000]
at org.eclipse.leshan.server.californium.request.LwM2mResponseBuilder.decodeCoapResponse(LwM2mResponseBuilder.java:458)
at org.eclipse.leshan.server.californium.request.LwM2mResponseBuilder.visit(LwM2mResponseBuilder.java:122)
at org.eclipse.leshan.core.request.ReadRequest.accept(ReadRequest.java:187)
at org.eclipse.leshan.server.californium.request.RequestSender$2.buildResponse(RequestSender.java:226)
at org.eclipse.leshan.core.californium.AsyncRequestObserver$1.onResponse(AsyncRequestObserver.java:60)
at org.eclipse.leshan.core.californium.CoapAsyncRequestObserver.onResponse(CoapAsyncRequestObserver.java:99)
at org.eclipse.californium.core.coap.Request.setResponse(Request.java:931)
at org.eclipse.californium.core.server.ServerMessageDeliverer.deliverResponse(ServerMessageDeliverer.java:258)
at org.eclipse.californium.core.network.stack.BaseCoapStack$StackTopAdapter.receiveResponse(BaseCoapStack.java:217)
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:139)
at org.eclipse.californium.core.network.stack.BlockwiseLayer.receiveResponse(BlockwiseLayer.java:776)
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.core.network.stack.BaseCoapStack.receiveResponse(BaseCoapStack.java:146)
at org.eclipse.californium.core.network.CoapEndpoint$1.receiveResponse(CoapEndpoint.java:314)
at org.eclipse.californium.core.network.UdpMatcher$4.run(UdpMatcher.java:457)
at org.eclipse.californium.elements.util.SerialExecutor$1.run(SerialExecutor.java:290)
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:834)
Caused by: org.eclipse.leshan.core.node.codec.CodecException: Invalid content [1.638435E9] for type TIME for path /3/0/13
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.parseResourceValue(LwM2mNodeSenMLDecoder.java:504)
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.extractLwM2mResources(LwM2mNodeSenMLDecoder.java:426)
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.parseRecords(LwM2mNodeSenMLDecoder.java:193)
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.decode(LwM2mNodeSenMLDecoder.java:97)
at org.eclipse.leshan.core.node.codec.DefaultLwM2mDecoder.decode(DefaultLwM2mDecoder.java:156)
at org.eclipse.leshan.core.node.codec.DefaultLwM2mDecoder.decode(DefaultLwM2mDecoder.java:138)
at org.eclipse.leshan.server.californium.request.LwM2mResponseBuilder.decodeCoapResponse(LwM2mResponseBuilder.java:450)
... 21 common frames omitted
Caused by: java.lang.IllegalStateException: Can not convert 1.638435E9 to long safely : Unsupported number java.lang.Double
at org.eclipse.leshan.core.util.datatype.NumberUtil.numberToLong(NumberUtil.java:59)
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.numberToLong(LwM2mNodeSenMLDecoder.java:527)
at org.eclipse.leshan.core.node.codec.senml.LwM2mNodeSenMLDecoder.parseResourceValue(LwM2mNodeSenMLDecoder.java:493)
... 27 common frames omitted
Best regards,
Sonny
The text was updated successfully, but these errors were encountered: