Skip to content

Is not the same as the ProtoBuf decode rules #556

@cjhxajh

Description

@cjhxajh

protobuf.js v6.1.1
//TestPacke.proto
package TestPacke;
syntax = "proto3";

message TestMsgA
{
int32 X = 1;
int32 Y = 2;// Tag numbers 2
}
message TestMsgB
{
int32 X = 1;
int32 Y = 16;// Tag numbers 16
}

var TestMsgA= root.lookup("TestPacke.TestMsgA");
var TestMsgB= root.lookup("TestPacke.TestMsgB");

var messageA = TestMsgA.create({X=1,Y=2});
var messageB = TestMsgB.create({X=1,Y=2});

var bufferA = TestMsgA.encode(messageA ).finish();
var bufferB = TestMsgA.encode(messageB ).finish();

//bufferA .Lentgh = 4; bufferB.Lentgh = 4;

Use protobuf.js encode bufferA and bufferB lenght = 4

Use C# Google.Protobuf.dll 3.1.0
TestMsgA msgA = new TestMsgA(){ X =1,y=2} ;
TestMsgB msgB = new TestMsgB(){ X =1,y=2} ;
byte[] BytesA = msgA.ToByteArray();
byte[] BytesB = msgB.ToByteArray();

//BytesA.Lentgh = 4; BytesB.Lentgh = 5;

Why two conversion is not the same as a byte array length
Lead to sending data parsing errors

protobuf.js decode error
ReaderPrototype.skipType
throw Error("invalid wire type: " + wireType);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions