dotnet protocol_error ai_generated true

Grpc.Core.RpcException: Status(StatusCode="Unimplemented", Detail="Method 'YourMethod' is unimplemented.")

ID: dotnet/grpc-unimplemented-service

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Grpc.AspNetCore 2.57.0 active
Google.Protobuf 3.24.0 active
Grpc.Tools 2.57.0 active

Root Cause

The gRPC client calls a method that the server has not registered or implemented, often due to missing service binding or incorrect proto compilation.

generic

中文

gRPC 客户端调用了服务器未注册或未实现的方法,通常是由于缺少服务绑定或 proto 编译错误。

Official Documentation

https://learn.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-8.0#unimplemented-method

Workarounds

  1. 90% success Regenerate both client and server stubs from the same .proto file using 'dotnet grpc' or 'protoc' tool. Ensure the server's startup code maps the service: 'app.UseEndpoints(endpoints => { endpoints.MapGrpcService<MyServiceImpl>(); });'
    Regenerate both client and server stubs from the same .proto file using 'dotnet grpc' or 'protoc' tool. Ensure the server's startup code maps the service: 'app.UseEndpoints(endpoints => { endpoints.MapGrpcService<MyServiceImpl>(); });'
  2. 85% success Verify the service is registered in the DI container: 'services.AddGrpc();' and 'services.AddScoped<MyServiceImpl>();' before mapping in endpoints.
    Verify the service is registered in the DI container: 'services.AddGrpc();' and 'services.AddScoped<MyServiceImpl>();' before mapping in endpoints.

中文步骤

  1. 使用 'dotnet grpc' 或 'protoc' 工具从同一 .proto 文件重新生成客户端和服务器存根。确保服务器启动代码映射服务:'app.UseEndpoints(endpoints => { endpoints.MapGrpcService<MyServiceImpl>(); });'
  2. 验证服务已在 DI 容器中注册:'services.AddGrpc();' 和 'services.AddScoped<MyServiceImpl>();',然后在端点中映射。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Checking only the client-side proto file while the server uses an older version causes mismatch; both must be regenerated from the same .proto.

  2. 85% fail

    Restarting the server without recompiling the service code does not register new methods; the error persists.

  3. 60% fail

    Assuming the method name is case-insensitive in gRPC leads to wrong endpoint calls; gRPC method names are case-sensitive.