The length is these same on each side.
However binary it is something else on each side.

First of all I noted in python client that first byte of received message 
sporadically changes,
Secondly

This is serialized protobuf message to string in C++ server application 
0x08 0x02 0x10 0x01 0x18 0x00
This is received packet in ZMQ client written in python 0xe4 0x1f 0x02 0x00 
0x90 0xf6

So it is totally different..

On Tuesday, July 14, 2015 at 1:21:19 AM UTC+2, Ilia Mirkin wrote:
>
> Is what you're sending the same thing as what you're receiving? Do the 
> lengths match up? Pretty easy to buggily truncate at the first null 
> byte... 
>
> On Mon, Jul 13, 2015 at 5:22 PM,  <maqi...@gmail.com <javascript:>> 
> wrote: 
> > I'm developing zmq/protobuf application and I have a problem with 
> > deserialization of messages sent from C++ to python. I easily handle 
> > messages from python to C++ however in the other direction I have a 
> problem. 
> > 
> > Protobuf library in python client application complains that it detected 
> > 'Unexpected end-group tag.' 
> > 
> > I presume there is a problem between C++ serizalization and python 
> > deserialization. I'm wondering if there is some problem with null 
> terminator 
> > in C/C++ :(. 
> > 
> > This is my C++ serialization code.. 
> > 
> > // Test Code. 
> > // Try to send some 'demo' response back 
> > RPiProtocol::Message response; 
> > std::string response_string; 
> > response.set_type(RPiProtocol::Message::RESPONSE); 
> > response.set_command(RPiProtocol::Message::GET_SYS_INFO); 
> > response.set_version(0); 
> > 
> > // Serialize ZMQ message to string. 
> > if (response.SerializeToString(&response_string)) 
> > { 
> >     // Debug prints. 
> >     printf("%#010x\n", response_string.c_str()); 
> >     cout << "Response string length= " << response_string.length() << 
> endl; 
> > 
> >     //  Send response message back to the client. 
> >     zmq::message_t reply(response_string.length()); 
> >     memcpy((void *)reply.data(), &response_string, 
> > response_string.length()); 
> >     socket.send(reply); 
> > } 
> > 
> > This is my python deserialization code.. 
> > 
> > #  Get the reply. 
> > message = socket.recv() 
> > print len(message) 
> > print ':'.join(x.encode('hex') for x in str(message)) 
> > response = rpi_protocol_pb2.Message() 
> > 
> > # This line fails 
> > response.ParseFromString(message) 
> > 
> > I debugged that deserialization fails in this function 
> > \google\protobuf\internal\python_message.py 
> > 
> >   def InternalParse(self, buffer, pos, end): 
> >     self._Modified() 
> >     field_dict = self._fields 
> >     unknown_field_list = self._unknown_fields 
> >     while pos != end: 
> >       (tag_bytes, new_pos) = local_ReadTag(buffer, pos) 
> >       field_decoder, field_desc = decoders_by_tag.get(tag_bytes, (None, 
> > None)) 
> >       if field_decoder is None: 
> >         value_start_pos = new_pos 
> >         new_pos = local_SkipField(buffer, new_pos, end, tag_bytes) 
> >         if new_pos == -1: # HERE I HAVE -1 !!! 
> >           return pos 
> >         if not unknown_field_list: 
> >           unknown_field_list = self._unknown_fields = [] 
> >         unknown_field_list.append((tag_bytes, 
> > buffer[value_start_pos:new_pos])) 
> >         pos = new_pos 
> >       else: 
> >         pos = field_decoder(buffer, new_pos, end, self, field_dict) 
> >         if field_desc: 
> >           self._UpdateOneofState(field_desc) 
> >     return pos 
> >   cls._InternalParse = InternalParse 
> > 
> > C++ (ZMQ SERVER - REP): http://pastebin.com/ACaXk8Vz 
> > 
> > PYTHON (ZMQ CLIENT - REQ): http://pastebin.com/X9DR8ue9 
> > 
> > Could you help me with enabling my application? 
> > 
> > -- 
> > 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 protobuf+u...@googlegroups.com <javascript:>. 
> > To post to this group, send email to prot...@googlegroups.com 
> <javascript:>. 
> > Visit this group at http://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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to