Open sathishiitd opened 3 months ago
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive
because the last activity was over 90 days ago.
I am facing an issue in parsing Protobuf messages. The error says "Error parsing message with type 'AiServiceMsg'". my proto is as below syntax = "proto3"; message Bbox{ float x1=1; float y1=2; float x2=3; float y2=4; }
message AiServiceMsg{ string cameraId=1; string msgType=2; Bbox box=3; }
In my application, the protobuf message is created and serialized in C++ code. The serialized message is sent to RabbitMQ. A Python application is receiving the serialized protobuf message and trying to parse it.
C++ code is as below: void generate_dsmeta_message_protobuf() { AiServiceMsg ai_service_msg;
Bbox* box = ai_service_msg.mutable_box(); box->set_x1(11); box->set_y1(11); box->set_x2(22); box->set_y2(22);
int size = ai_service_msg.ByteSize(); gchar* data = new gchar[size];
// data is sent to RabbitMQ return; } Python Code:
def pb_convert(self): try: for method, properties, body in self.channel.consume( self._queue_name, inactivity_timeout=1000 ): if body is not None:
msg = AiServiceMsg() print(body) try: msg.ParseFromString(body) print(msg.cameraId) print(msg.msgType) except Exception as err: print( err)
In Python code, I received the below exception.
Error parsing message with type 'AiServiceMsg'
I can decode protobuf messages in C++ using the below code AiServiceMsg ai_msg; if (!ai_msg.ParseFromArray(data, size)) { cout << "Parsing failed\n"; } { std::lock_guard lock(mu);
cout << ai_msg.cameraid() << " " << ai_msg.msgtype() << " " << ai_msg.box().x1() << " " << ai_msg.box().y1()
<< " " << ai_msg.box().x2() << " " << ai_msg.box().y2() << "\n";
}
Why I am not able to decode the protobuf message in Python