(I'm assumig the "optional" isn't there in the real example) You can't simply change between proto2 and proto3. In proto3 everything is optional with an implicit zero default. This is fundamentally incompatible with consumers who have a "required" expectation **unless** you happen to never send the value zero. Because whenever your value is zero, it will be omitted and the consumer will complain about a missing required field.
Options: - update the consumers **first** so that they don't have a "required" expectation - never send zero in that field - don't change to proto3 Marc On 16 Jun 2017 10:04 p.m., "yihao yang" <yangyihao1...@gmail.com> wrote: > I updated a proto file from proto2 to proto3 as follows. > > Previous proto2: > message RegisterWatcherResponse { > required int32 rc = 1; > optional uint64 sendTime = 2; > } > > > Now proto3: > message RegisterWatcherResponse { > int32 rc = 1; > optional uint64 sendTime = 2; > } > > I tested compatibility by using old version client with using proto2 > RegisterWatcherResponse and receiving responses from a server using > proto3 RegisterWatcherResponse. > It turns out clients got failure message like follows: > [libprotobuf ERROR google/protobuf/message_lite.cc:118] Can't parse > message of type "RegisterWatcherResponse" because it is missing required > fields: rc > I'm sure the server side responses have rc filed. > Can anyone help me why I got this error? Is proto3 compatible with proto2 > in this scenario? > What can I do to make it work? > > Thanks, > Yihao > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to protobuf+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.