Task #4982
closedError in sending/receiving parameters in Interest using setApplicationParameters
0%
Description
Trying to send an interest using the Java client, to a Cpp Server listening to the same prefix, I got the error,
ERROR: ParametersSha256DigestComponent does not match the SHA-256 of Interest parameters
This behaviour is observed when using the method interest.setApplicationParameters
with non-empty Blob.
Meanwhile listening as a Java Server worked fine.
Files
Updated by Anonymous over 5 years ago
It looks like Cpp Server is written with ndn-cxx which is enforcing a check of the parameters.
Instead of setApplicationParameters, please try appendParametersDigestToName().
https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/Interest.java#L680
appendParametersDigestToName() was written according to the first spec of computing the Parameters digest. (From what I undersatand the spec is not finalized. I don't know which spec is used by your version of ndn-cxx.)
Updated by Ritik kumar over 5 years ago
I have used that here (uncomment!). But even after that, the error continues.
I have built the latest commit of ndn-cxx.
Updated by Anonymous over 5 years ago
There have been many changes to ndn-cxx for ApplicationParameters since the last release. I'm still waiting for the new digest calculation spec to be finalized.
In the mean time, can you call Interest::setAutoCheckParametersDigest(false)
?
Updated by Anonymous over 5 years ago
(Call it in the Cpp Server app which is throwing the error.)
Updated by Ritik kumar over 5 years ago
Thanks for the help, the Cpp server doesn't crash now but there's a new problem!
The received Block
on the Cpp Server gets a size 2 more than that of the Blob
sent from the Java Client. Consequently, this results in parsing errors. (I have updated the files on the link to print this difference)
Updated by Anonymous over 5 years ago
Can you please post the two different printouts so that I don't have to compile and run your code?
Updated by Ritik kumar over 5 years ago
- File Screenshot from 2019-08-15 17-58-27.png Screenshot from 2019-08-15 17-58-27.png added
- File Screenshot from 2019-08-15 17-56-01.png Screenshot from 2019-08-15 17-56-01.png added
For the Server
and for the Client
Updated by Anonymous over 5 years ago
Can you print the hex of the Received Block? I suspect that it is the entire TLV of the ApplicationParameters, including the type and length bytes 0x24 0x12. You need to use the correct ndn-cxx code to just get the value from the Received Block TLV.
Also, why do you use paramFromJson? The parameters are already encoded in a JSON string (of 16 bytes). You don't need to encode them again into a TLV. You can just put the JSON string as the value of the ApplicationParameters.
https://gist.github.com/dev-ritik/d5ba9ea2bbebad0a2bfd9cb0fe03bb0f#file-client-java-L27
Instead of
Blob blob = paramFromJson(jo.toString());
just use
Blob blob = new Blob(jo.toString().getBytes());
Updated by Ritik kumar over 5 years ago
Thanks for the prompt help, the error was fixed following what you suggested above.