0

I have one proto file in client and one in server, but the field numbers in client protobuf for a particular attribute has to be same in server proto.

message Foo_client {
    string foo_has = 1;
    string bar_has = 3;
 }

message Foo_server {
    string bar_true = 1;
    string foo_true = 2;
    string bar_has = 3;
 }

since in server proto file attribute "bar_has" had tag=3 ,so in client it has to be 3  
why?? and is there any other solution that we can use to remove this ambiguity

1 Answers1

0

Please be clearer about your query. From what I can understand from it, you don't have two separate proto files for your server and client. The whole point of defining a proto file is to have a consistent handshake defined between your server and client.

You cannot skip a number as it is incremental. The structs you should be defining should be based on request/response and not server/client.

Devaj Mody
  • 18
  • 2
  • I have two separate proto files in client and server both, but the issue is if the client proto file has an attribute which has field number say 2, and the same attribute is in server proto also , it has to have field number 2 , but why?? this was my question. – Neelam Gupta May 15 '20 at 09:21
  • It's a handshake. Do you mean you have two different proto files when you say separate? You're defining your structure. If the server says it accepts an integer called Index at position one, the client has to respect that and maintain the same handshake. – Devaj Mody May 16 '20 at 13:22