I built a small c++ test server and client app using protocol buffers over sockets.
The server sends several packets made up of
- a 32 bit marker (0xDEADBEEF)
- a 32 bit size of message
- the message data.
The message format is
message IQEvent {
required int32 id = 1; // instance ID
required int32 type = 2; // message type
optional string description = 3 [default = ""];
}The client then just reads these back out.
I'm getting a parser error on the client for each message read:
'Can't parse message of type "..." because it is missing required fields: id.
If I print out the hex bytes of what is sent and what is received they are identical.
Each marker and size is seen correctly.
Even after the error message, If I print out the description string it appears correct.
I'm using a CodedOutputStream wrappered around an ArrayOutputStream to write and a CodedInputStream (CIS) wrappered around an ArrayInputStream to read from the socket.
I do set the limit on the CIS during the parsing
CodedInputStream::Limit msgLimit = cis2.PushLimit(nMsgSize);
anEvent.ParseFromCodedStream(&cis2);
cis2.PopLimit(msgLimit);If I step through the parsing, I can see the IQEvent parse the type and description fields.
After that there are 2 bytes left in the buffer, but the CodedInputStream->ReadTag() returns 0.
Any thoughts as to why this error could be occuring?
Thanks,
Chris