12 dotnet protocol_error ai_generated true

Grpc.Core.RpcException: Status(StatusCode="Unimplemented", Detail="Method 'ServiceName/MethodName' is unimplemented. If the server is not configured to serve this method, the call will fail.")

ID: dotnet/grpc-unimplemented-method

Also available as: JSON · Markdown · 中文
90%Fix Rate
88%Confidence
1Evidence
2023-08-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2.45.0 active
2.46.0 active
2.47.0 active
2.48.0 active

Root Cause

The gRPC client calls a method that the server does not have a handler registered for, often due to missing service registration, incorrect proto file compilation, or version mismatch between client and server.

generic

中文

gRPC 客户端调用了服务器未注册处理程序的方法,通常是由于缺少服务注册、proto 文件编译错误或客户端与服务器版本不匹配。

Official Documentation

https://grpc.io/docs/guides/error/

Workarounds

  1. 90% success Ensure the service is registered in the DI container and endpoint mapping: in Program.cs, add 'app.MapGrpcService<MyServiceImpl>();' and in the service class, inherit from 'MyService.MyServiceBase' and override the method.
    Ensure the service is registered in the DI container and endpoint mapping: in Program.cs, add 'app.MapGrpcService<MyServiceImpl>();' and in the service class, inherit from 'MyService.MyServiceBase' and override the method.
  2. 85% success Regenerate gRPC stubs by running 'dotnet build' after updating the .proto file, or use 'dotnet grpc-aspnetcore-codegen' to ensure both client and server use the same proto definition.
    Regenerate gRPC stubs by running 'dotnet build' after updating the .proto file, or use 'dotnet grpc-aspnetcore-codegen' to ensure both client and server use the same proto definition.

中文步骤

  1. Ensure the service is registered in the DI container and endpoint mapping: in Program.cs, add 'app.MapGrpcService<MyServiceImpl>();' and in the service class, inherit from 'MyService.MyServiceBase' and override the method.
  2. Regenerate gRPC stubs by running 'dotnet build' after updating the .proto file, or use 'dotnet grpc-aspnetcore-codegen' to ensure both client and server use the same proto definition.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    Restarting the server without updating the code does not add the missing method handler; the service must be properly registered in Startup.cs or Program.cs.

  2. 70% fail

    Adding a new proto file without regenerating the server stubs leaves the server unaware of the method; the build step must compile the proto to C#.