go type_error ai_generated true

rpc错误:代码=未实现 描述=方法/myservice.MyService/StreamData是流式方法,但客户端使用了非流式调用

rpc error: code = Unimplemented desc = method /myservice.MyService/StreamData is a streaming method but the client is using unary call

ID: go/grpc-unimplemented-streaming-not-supported

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2025-12-01首次发现

版本兼容性

版本状态引入弃用备注
1.0 active
1.1 active

根因分析

客户端尝试使用非流式RPC存根调用服务器流式或双向流式方法。

English

The client attempted to call a server-streaming or bidirectional streaming method using a unary RPC stub.

generic

解决方案

  1. 95% 成功率 Use the correct streaming client stub for the method.
    stream, err := client.StreamData(ctx, &pb.StreamRequest{})
    if err != nil { return err }
    for {
        resp, err := stream.Recv()
        if err == io.EOF { break }
        if err != nil { return err }
        // process resp
    }
  2. 90% 成功率 Regenerate protobuf code to ensure proper client stubs are created.
    protoc --go_out=. --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false myservice.proto

无效尝试

常见但无效的做法:

  1. Use the same stub but with different parameters. 100% 失败

    The stub type is fixed; unary stub cannot handle streaming methods.

  2. Ignore the error and treat the response as a single message. 100% 失败

    The server expects a stream; the client must use the correct streaming API.