Unable to get through error: Protocol message contained an invalid tag (zero).

9,601 views
Skip to first unread message

Vishal Singh

unread,
Feb 5, 2016, 4:38:03 PM2/5/16
to Protocol Buffers
Hi,

I am building an application using Sitewhere in which the message exchange between device and the server is done using Protocol Buffer format. The server sends a command to the device after converting the message in this format, but at the device end when the bytes array is converted to get the command, following exception is thrown:

 com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
     at com.google.protobuf.CodedInputStream.readTag(CodedInputStream.java:108)
     at com.sitewhere.android.generated.Android$AndroidSpecification$_Header.<init>(Android.java:212)
     at com.sitewhere.android.generated.Android$AndroidSpecification$_Header.<init>(Android.java:203)
     at com.sitewhere.android.generated.Android$AndroidSpecification$_Header$1.parsePartialFrom(Android.java:255)
     at com.sitewhere.android.generated.Android$AndroidSpecification$_Header$1.parsePartialFrom(Android.java:1)
     at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:200)
     at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:241)
     at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:253)
     at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:259)
     at com.google.protobuf.AbstractParser.parseDelimitedFrom(AbstractParser.java:49)
     at com.sitewhere.android.generated.Android$AndroidSpecification$_Header.parseDelimitedFrom(Android.java:410)
     at com.sitewhere.android.example.SiteWhereExample.onReceivedCustomCommand(SiteWhereExample.java:273)
     at com.sitewhere.android.SiteWhereActivity$SiteWhereResponseProcessor.receivedCustomCommand(SiteWhereActivity.java:231)
     at com.sitewhere.android.mqtt.RegistrationManager.onCustomCommandReceived(RegistrationManager.java:112)
     at com.sitewhere.android.mqtt.DefaultMqttInteractionManager$MqttMessageProcessor.run(DefaultMqttInteractionManager.java:139)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)

I have no clue what is the meaning of "Protocol message contained an invalid tag (zero)". Please help. The byte array received from the server is:

Josh Haberman

unread,
Feb 9, 2016, 2:09:53 PM2/9/16
to Protocol Buffers
Hi Vishal,

The message basically means that the protobuf is corrupted (or isn't a protobuf at all).

The message is giving you more detail on the specific kind of data corruption. Protocol buffers don't allow tag number 0 -- you can't define a field like "int32 a = 0". But the binary protobuf you tried to parse contained a tag with field number zero. So parsing the protobuf failed.

Josh

Hana Agustin

unread,
Feb 24, 2016, 1:27:54 PM2/24/16
to Protocol Buffers
Unable to get thhrocol error: protocol messages
Reply all
Reply to author
Forward
0 new messages