1

When calling my server for a type of message, I got the following error: Exception calling application: module \'grpc\' has no attribute \'experimental\', grpc-status: 2};.

This error happened right after the server received the call. The service is able to validate the format of the message (if I pass a wrong format, I will receive the correct error)

I have other services running my server without any issues.

My server is defined as following:

       Settings.load_settings()
        server = grpc.server(
            futures.ThreadPoolExecutor(max_workers=int(os.getenv("WORKER_NB")))
        )

        Compiler(server).compile_controllers()
        SQLProvider()

        # Add Health checking:
        health_pb2_grpc.add_HealthServicer_to_server(health.HealthServicer(), server)

        # Start the server:
        server.add_insecure_port("[::]:{}".format(os.getenv("API_PORT")))
        server.start()
        logger.info("Server started")
        server.wait_for_termination()

The main difference I can find in the call is that the protobuf message contains timestamps and enums. Is there an option to pass to the server ?

The proto message I am trying to pass looks like that:

syntax = "proto3";
import "google/protobuf/timestamp.proto";

enum En {
  a = 0;
  b = 1;
  c = 2;
}

message ComputeRequest {
    int32 a = 2;
    google.protobuf.Timestamp start_date = 3;
    repeated int32 ids = 7;
    En en = 11;
}

message ComputeResponse {
  float a = 1;
  float b = 2;
}

service ComputeService {
    rpc GetComputeResponse (ComputeRequest) returns (ComputeResponse) {}
}

grpc version: 1.54.2

Does on of you have any idea about how I can fix this issue ?

Adrien
  • 11
  • 1
  • Which version of the gRPC library are you using? It can be a version mismatch between your lib and the actual gRPC. – Renê Cardozo Jun 06 '23 at 19:15
  • I encountered this recently in another [question](https://stackoverflow.com/questions/76266703/python-m-grpc-tools-protoc-uses-experimental-grpc-apis). Try adding `import grpc.experimental` – DazWilkin Jun 06 '23 at 19:56
  • Thank you @DazWilkin, this is working! I get another error right after : `Exception calling application: '_Context' object has no attribute 'encode'`. I guess the solution will be the same as in the post you mentioned : Create the channel myself. – Adrien Jun 07 '23 at 07:47
  • I found a solution. I changed the definition of my service from `GetComputeResponse ` to `GetServerResponse` and it solved my issue. I still don't know why. – Adrien Jun 12 '23 at 12:41

0 Answers0