No, both the client and server run in the same anaconda environment and the proto import path are the same.
Thanks & Best Wishes! Jiongjiong Li On Tuesday, September 11, 2018 at 1:35:29 AM UTC+8, Carl Mastrangelo wrote: > > As a sanity check, are the client and server both using the same generated > code? Protobuf will ignore fields it doesn't know about by default. In > your case, it sounds like you may have modified the proto on one side. Is > this the case? > > On Monday, September 10, 2018 at 3:05:24 AM UTC-7, [email protected] > wrote: >> >> The repeated field of protobuf message is always empty on the gRPC client >> side even though I set it on the gRPC server side. >> Is there any way to fix this issue? >> >> >> >> - helloworld.proto file: >> >> syntax = "proto3"; >> >> package helloworld; >> >> // The greeting service definition. >> service Greeter { >> // Sends a greeting. >> rpc SayHello (HelloRequest) returns (HelloReply) {} >> } >> >> // The request message containing the user's name. >> message HelloRequest { >> string name = 1; >> } >> >> // The response message containing the greetings. >> message HelloReply { >> string message = 1; >> repeated string snippets = 2; >> } >> >> >> >> >> >> - server.py >> >> from __future__ import absolute_import >> from __future__ import division >> from __future__ import print_function >> >> from concurrent import futures >> import time >> >> import grpc >> >> import grpc_demo.lib.protos.helloworld_pb2 as helloworld_pb2 >> import grpc_demo.lib.protos.helloworld_pb2_grpc as helloworld_pb2_grpc >> >> >> _ONE_DAY_IN_SECONDS = 60 * 60 * 24 >> >> class Greeter(helloworld_pb2_grpc.GreeterServicer): >> >> def SayHello(self, request, context): >> reply = helloworld_pb2.HelloReply(message='Hello, %s!' % >> request.name) >> reply.snippets.append('test-snippets') >> # print('reply:' + reply) >> return reply >> >> def main(): >> """Main entrance.""" >> >> server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) >> helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), >> server) >> server.add_insecure_port('[::]:50051') >> server.start() >> try: >> while True: >> time.sleep(_ONE_DAY_IN_SECONDS) >> except KeyboardInterrupt: >> server.stop(0) >> >> >> if __name__ == '__main__': >> main() >> >> >> >> >> >> - client.py >> >> from __future__ import absolute_import >> from __future__ import division >> from __future__ import print_function >> >> import grpc >> >> import grpc_demo.lib.protos.helloworld_pb2 as helloworld_pb2 >> import grpc_demo.lib.protos.helloworld_pb2_grpc as helloworld_pb2_grpc >> >> def main(): >> """Main entrance.""" >> >> # NOTE(gRPC Python Team): .close() is possible on a channel and >> should be >> # used in circumstances in which the with statement does not fit >> the needs >> # of the code. >> with grpc.insecure_channel('localhost:50051') as channel: >> stub = helloworld_pb2_grpc.GreeterStub(channel) >> response = >> stub.SayHello(helloworld_pb2.HelloRequest(name='you')) >> print("Greeter client received: " + response.message + ', >> '.join(response.snippets) >> + str(len(response.snippets))) >> >> >> if __name__ == '__main__': >> main() >> >> >> >> >> - Expected Result: >> >> >> *Greeter client received: Hello, you!test-snippets1* >> >> >> - Actual Result: >> >> >> *Greeter client received: Hello, you!0* >> >> Thanks! >> Jiongjiong Li >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/a302f9bb-0d4c-4026-94ae-bee6f5591d2e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
