I am using **protobuf** now for some weeks, but I still keep getting
exceptions when parsing protobuf messages in **Java**.

I use **C++** to create my protobuf messages and send them with
**boost sockets** to a server socket where the Java client ist
listening. The C++ code for transmitting the message is  this:

        boost::asio::streambuf b;
        std::ostream os(&b);

        ZeroCopyOutputStream *raw_output = new OstreamOutputStream(&os);
        CodedOutputStream *coded_output = new CodedOutputStream(raw_output);


        delete coded_output;
        delete raw_output;

        boost::system::error_code ignored_error;

        boost::asio::async_write(socket, b.data(), boost::bind(
                        &MessageService::handle_write, this,

As you can see I write with `WriteVarint32` the length of the message,
thus the Java side should know by using `parseDelimitedFrom` how far
it should read:

    AgentMessage agentMessage = AgentMessageProtos.AgentMessage

But it's no help, I keep getting these kind of Exceptions:

    Protocol message contained an invalid tag (zero).
    Message missing required fields: ...

It is **important** to know, that these exceptions are not thrown on
every message. This is only a fraction of the messages I receive the
most work out just fine - still I would like to fix this since I do
not want to omit the messages.

I would be really gratful if someone could help me out or spent his

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to