dongshou1856 2019-05-08 06:49
浏览 666

rpc错误:代码=未实现的desc =未实现RPC方法

I have been trying to create a grpc client in Go and I have followed the correct instructions as shown in the official grpc site. When I start my grpc server written in node.js, the connection works well but upon compiling the protocol buffer in Go and creating a client interface with the correct grpc client configurations, I run into an error.

Here is my what I have in my identity.pb.go.

type IdentityServiceClient interface {
    CreateUser(ctx context.Context, in *GoogleIdToken, opts ...grpc.CallOption) (error, *UserInfo)
}

type simpleServerClient struct {
    connection *grpc.ClientConn
}

func NewSimpleServerClient(connection *grpc.ClientConn) IdentityServiceClient {
    return &simpleServerClient{connection}
}

func (simpleClient *simpleServerClient) CreateUser(ctx context.Context, in *GoogleIdToken, opts ...grpc.CallOption) (error, *UserInfo) {
    out := new(UserInfo)
    err := simpleClient.connection.Invoke(ctx, "/protobuf.IdentityService/CreateUser", in, out, opts...)

    if err != nil {
        return err, nil
    }

    return nil, out
}

here is the identity.proto

syntax="proto3";

package protobuf;

service IdentityService {
    rpc CreateUser (GoogleIdToken) returns (UserInfo) {}
}

message GoogleIdToken {
    string token = 1;
}

message UserInfo {
    string name = 1;
    string email = 2;
    message Profile {
        string imageUrl = 1;
        string lastUpdated = 2;
    };
    Profile profile = 3;
    string token = 4;
}

here is my main.go

import pb "github.com/Duncanian/iam-gateway/server/protobuf"

func grpcConnection() {
    conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
    if err != nil {
        log.Fatalf("Failed to start gRPC connection: %v", err)
    }

    defer conn.Close()

    client := pb.NewSimpleServerClient(conn)

    err, _ = client.CreateUser(context.Background(), &pb.GoogleIdToken{Token: "tevgvybububvvg"})
    if err != nil {
        log.Fatalf("Failed to create user: %v", err)
    }
    log.Println("Created user!")
}

I expect the output of passing a correct google auth token to get me the correct user details which are

name: user,
email: user.email@user.com,
profile: {
   imageUrl: myimageUrl,
   lastUpdated: mylastUpdatedTime,
},
token,

but got

rpc error: code = Unimplemented desc = RPC method not implemented /protobuf.IdentityService/CreateUser

Here are my github repos: Go grpc client & Node JS grpc server

  • 写回答

1条回答 默认 最新

  • douqi2804 2019-05-08 18:24
    关注

    The error indicates that the /protobuf.IdentityService/CreateUser method is not registered at the server side. And I didn't see any service registration code in your linked server code. Please take a look at the node.js guide here.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100