Hi Feng

Thanks for the suggestion.  I'll let you and the group know what happens.

Howard
________________________________
From: Feng Xiao [xiaof...@google.com]
Sent: Monday, October 28, 2013 1:39 PM
To: Howard Lander
Cc: Protocol Buffers
Subject: Re: [protobuf] Hard to understand message from protobu




On Mon, Oct 28, 2013 at 10:17 AM, Howard 
<how...@renci.org<mailto:how...@renci.org>> wrote:
Hi all

When I run the server side of my protobuf enabled application I am seeing a 
diagnostic message I am having a hard time understanding. Here is the stdout 
including some diagnostic messages I have added:

Parsing request in worker thread :
[libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse message of 
type "proto_wos.RequestUnion" because it is missing required fields: type
After Parsing request in worker thread :
    Request type is: 1

I'm using the C++ binding of zeromq as the transport: Here's the code that 
produced the above output

 43         socket.recv (&request);
 44         try {
 45            cout << "\nParsing request in worker thread :" << "\n";
 46            theRequest.ParseFromArray(request.data(), request.size());
 47            cout << "After Parsing request in worker thread :" << "\n";
 48            cout << "\tRequest type is: " <<  theRequest.type() << "\n";
 49         } catch (std::exception& e) {
 50            cout << "\nException in Request Parsing in worker thread :" << 
"\n";
 51            cout << "\t" << e.what() << "\n\n";
 52         }
 53
 54         // Switch on the request type
 55         switch (theRequest.type()) {

Note that the value for the type field in the RequestUnion field is outputted 
in line 48, and it is the value my client app asserted. I'm assuming the error 
message is coming from line 46, but I could be convinced I'm wrong. The switch 
statement in line 55 executes correctly, in fact the whole server executes 
correctly, but I am suspicious and unhappy about the error from message_lite.  
I was using the yum install protobuf version, so I downloaded and installed the 
latest from the web site.  Same issue.  A Google search showed some other folks 
with a similar issue, but yielded no answer.  Any suggestions?
It seems you are trying to log the value of theRequset.type() to determine 
whether the "type" field is set. However, the result you have seen doesn't mean 
it's set though because 1 is the default value of the "type" field (i.e., if 
it's not set, theRequest.type() will return 1).
To be certain whether the field is set, first you need to use one of the 
"ParsePartialXXX" methods to parse the message, make sure the parsing is 
successful, and then check theRequest.has_type().


For reference, here's the relevant proto file

package proto_wos;
import "create.proto";
import "init.proto";

message RequestUnion {
   enum message_type {CreateRequestMessage = 1; InitRequestMessage = 2;}

   required message_type type = 1;

   optional CreateRequest create_request= 2;
   optional InitRequest   init_request = 3;
}

message ResponseUnion {
   enum message_type {CreateResponseMessage = 1; InitResponseMessage = 2;}
   enum rc_enum  { Enum_OK = 0; Enum_InvalidMessage = 1;}

   required message_type type = 1;
   required int32       return_code = 2;

   optional CreateResponse create_response = 3;
   optional InitResponse init_response = 4;
}

Thanks much for any ideas.
Howard

--
Howard Lander<mailto:how...@renci.org>
Senior Research Software Developer
Renaissance Computing Institute (RENCI)<http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651<tel:919-445-9651>

--
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<mailto:protobuf%2bunsubscr...@googlegroups.com>.
To post to this group, send email to 
protobuf@googlegroups.com<mailto:protobuf@googlegroups.com>.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/groups/opt_out.

Reply via email to