msgpack-cli icon indicating copy to clipboard operation
msgpack-cli copied to clipboard

Issue with difference in size of message Pack based on different language (C# and Ruby)

Open Rahul-Sharma-87 opened this issue 7 years ago • 3 comments

Hi,

Data sent from C# gives warning in ruby while unpacking show extra bytes. If there is missing interop then how it could be helpful using same framework (msgpack) in different languages.

I have created an issue at below: ------ https://github.com/msgpack/msgpack-ruby/issues/156 I m facing issue where same message Packed with the ruby and C# has different number of bytes and where ruby code msgpack library gives below warning while unpacking: Error in processing message. error_class=MessagePack::MalformedFormatError error=#### <MessagePack::MalformedFormatError: 11 extra bytes after the deserialized object>

My intention is to send data from c# to ruby program.

Message in ruby: [works fine] ["test3.aa",time,{"a"=>1}].to_msgpack

Message in C# [Shows warning message for extra bytes on unpack] Object[] test1 = new Object[3] {"test3.aa", 1308466941, new {a =1}};


According to me it should be unified irrespective of technology. Please let me know if you have another way to achieve the same. I m using fluentD which gets shipped with msgpack gems where i m seeing this issue.

Thanks in advance, Rahul

Rahul-Sharma-87 avatar Mar 28 '18 08:03 Rahul-Sharma-87

Sorry for delay. If you still interested in this issue, it is happy to put serialized binaries (by Ruby, and by MsgPack for CLI).

yfakariya avatar Jun 05 '18 12:06 yfakariya

I have the same issue between Java and C# messages serialized with Java then deserialized with C# results in the same message object. However, when I re-serialize that object in C#, the resulting bytes are quite different. This fails my unit tests because I would expect MessagePack to serialize/deserialize the same byte array regardless of language. Using this tool (https://kawanet.github.io/msgpack-lite/) I can see that the serialized bytes from Java and from C# are different, but they result in the same JSON object.

JonMcPherson avatar Jul 04 '18 23:07 JonMcPherson

@JonMcPherson

Thank you. I will discuss by example data posted by @Rahul-Sharma-87.

I put the ["test3.aa", 1308466941, {"a": 1}] in msgpack-lite and got 93 A8 74 65 73 74 33 2E 61 61 CE 4D FD 9E FD 81 A1 61 01. Is this your "expected" result? If so, you can get expected result by setting SerializationMethod.Map to SerializationContext. This option improves compatibility and interoperability at the cost of speed and data size by serializing objects as "map" instead of "array".

Of course, it is happy and welcome to tell your problem in detail!

yfakariya avatar Jul 16 '18 11:07 yfakariya