I've been tinkering about this all night, but with a fresh view in the 
morning I still can' t understand what is wrong here. The line where the 
error originates is this: beat.ParseFromString(message)

This is the *exact* same line which I use on the other end to parse the 
message. I googled the error (*"expected a character, but string of length 
2 found*") and it seems to have something to do with unicode strings. But I 
don't make use of unicode at all.

I start wondering if zeromq does something wrong but I couldn't imagine 
what. I tested the code with just sending a string ('beat') and that worked 
fine. The error only occured from the moment I used protobuf serialization.

Here is the code on pastebin with the error on line 54: 
http://pastebin.com/aJLCn7TM

Any help?



Op vrijdag 22 maart 2013 01:37:16 UTC+1 schreef kramer65 het volgende:
>
> Hello,
>
> I am doing some tests with protobuf and I run into a strange error. I 
> serialize a message (just one int32) which I send as a heartbeat via 
> zeromq. When it is received on the other end I can parse it and print it. 
> If I send the exact same message back (either the unpacked message or the 
> same int repacked) I get an error while parsing it back in the first 
> script. The strange thing is that it first succeeds to parse, but after 
> sending it back it gives the error below.
>
> Would anybody know whats wrong here? All tips are welcome!
>
>
> ERROR:root:Uncaught exception, closing connection.
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 414, in _run_callback
>     callback(*args, **kwargs)
>   File "heartBeat.py", line 56, in handleHeartBeat
>     beat.ParseFromString(message)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/message.py",
>  
> line 179, in ParseFromString
>     self.MergeFromString(serialized)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 755, in MergeFromString
>     if self._InternalParse(serialized, 0, length) != length:
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 774, in InternalParse
>     (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/decoder.py",
>  
> line 172, in ReadTag
>     while ord(buffer[pos]) & 0x80:
> TypeError: ord() expected a character, but string of length 2 found
> ERROR:root:Uncaught exception, closing connection.
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 440, in _handle_events
>     self._handle_recv()
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 472, in _handle_recv
>     self._run_callback(callback, msg)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 414, in _run_callback
>     callback(*args, **kwargs)
>   File "heartBeat.py", line 56, in handleHeartBeat
>     beat.ParseFromString(message)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/message.py",
>  
> line 179, in ParseFromString
>     self.MergeFromString(serialized)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 755, in MergeFromString
>     if self._InternalParse(serialized, 0, length) != length:
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 774, in InternalParse
>     (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/decoder.py",
>  
> line 172, in ReadTag
>     while ord(buffer[pos]) & 0x80:
> TypeError: ord() expected a character, but string of length 2 found
> ERROR:root:Exception in I/O handler for fd <zmq.core.socket.Socket object 
> at 0x9bfd23c>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/ioloop.py",
>  
> line 346, in start
>     self._handlers[fd](fd, events)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 440, in _handle_events
>     self._handle_recv()
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 472, in _handle_recv
>     self._run_callback(callback, msg)
>   File 
> "/usr/local/lib/python2.7/dist-packages/pyzmq-2.2.0.1-py2.7-linux-i686.egg/zmq/eventloop/zmqstream.py",
>  
> line 414, in _run_callback
>     callback(*args, **kwargs)
>   File "heartBeat.py", line 56, in handleHeartBeat
>     beat.ParseFromString(message)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/message.py",
>  
> line 179, in ParseFromString
>     self.MergeFromString(serialized)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 755, in MergeFromString
>     if self._InternalParse(serialized, 0, length) != length:
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/python_message.py",
>  
> line 774, in InternalParse
>     (tag_bytes, new_pos) = local_ReadTag(buffer, pos)
>   File 
> "/usr/local/lib/python2.7/dist-packages/protobuf-2.4.1-py2.7.egg/google/protobuf/internal/decoder.py",
>  
> line 172, in ReadTag
>     while ord(buffer[pos]) & 0x80:
> TypeError: ord() expected a character, but string of length 2 found
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to