12 dotnet protocol_error ai_generated true

Grpc.Core.RpcException: Status(StatusCode="Unimplemented", Detail="方法 'ServiceName/MethodName' 未实现。如果服务器未配置为提供此方法,调用将失败。")

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

其他格式: JSON · Markdown 中文 · English
90%修复率
88%置信度
1证据数
2023-08-20首次发现

版本兼容性

版本状态引入弃用备注
2.45.0 active
2.46.0 active
2.47.0 active
2.48.0 active

根因分析

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

English

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

官方文档

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

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 90% 失败

    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% 失败

    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#.