Could you provide some short snippets of your C++ code that generates the proto and your Java code for parsing it? I think the most common problem in this kind of scenario is framing the message properly. Serialized protocol buffers are not self-delimiting (they don't tell you their size), so you have to have some separate mechanism for knowing how many bytes to read when you parse the message. If you read too few or too many bytes, then you can end up getting the wrong result.
On Tue, Jun 12, 2018 at 8:39 AM Sagar Shah <[email protected]> wrote: > I'm trying to build a solution in which a C++ application is sending a > protobuf message to Java application. > > I noticed that parser function generated in C++ and java is different > because of which the parsing of the message fails. > > Sample proto message - > > message myMsg > { > myHeader header = 1; > > repeated uint64 obj1 = 2 [packed = true]; > repeated int64 obj2 =3 [packed =true]; > repeated uint64 obj3= 4 [packed = true]; > repeated int64 obj4 =5 [packed =true]; > > uint32 obj5= 6; > uint32 obj6= 7; > uint32 obj7= 8; > Struct1 obj8 = 9; > bool obj9 = 10; > } > > I'm setting obj8 in above structure. obj8 is of type struct1. > C++ application serializes the proto and it is like below - > 10 2 8 2 34 4 8 1 16 1 > > However when i parse the message via java protobuf, it recognizes the > message as from myMsg structure. but does not set the obj8 field. > > When i see the java method which de-serializes the method, i see dfiferent > ids for the tags.! Like 34 is taken for obj2 and java method populates obj2! > > I'm using protoc 3.5.1 > > Any pointers on this would be greatly appreciated. > > > Thanks! > Sagar Shah > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
