New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is not the same as the ProtoBuf decode rules #556

cjhxajh opened this Issue Dec 14, 2016 · 0 comments


None yet
2 participants

cjhxajh commented Dec 14, 2016

protobuf.js v6.1.1
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
throw Error("invalid wire type: " + wireType);

@cjhxajh cjhxajh changed the title from Is not the same as the ProtoBuf parsing rules to Is not the same as the ProtoBuf decode rules Dec 14, 2016

@dcodeIO dcodeIO closed this in b0aef62 Dec 14, 2016

@dcodeIO dcodeIO added the bug label Dec 14, 2016

dcodeIO added a commit that referenced this issue Dec 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment