UNIMPLEMENTED: RPC method not implemented xxxxx(nodejs客户端, java服务端)

grpc客户端:nodejs实现
grpc服务端:java实现

客户端报错如下:

Error receiving telemetry: Error: 12 UNIMPLEMENTED: Method not found: com.widgets.grpc.api.DeviceService/telemetry
    at Object.exports.createStatusError (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\common.js:91:15)
    at ClientReadableStream._emitStatusIfDone (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client.js:233:26)    
    at ClientReadableStream._receiveStatus (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client.js:211:8)        
    at Object.onReceiveStatus (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client_interceptors.js:1277:15)      
    at InterceptingListener._callNext (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client_interceptors.js:618:8)
    at E:\gitee\sight-front-end\sight-front-end\node_modules\grpc\src\client_interceptors.js:1033:24 {
  code: 12,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'Method not found: com.widgets.grpc.api.DeviceService/telemetry'
}

修改前:

# nodejs端proto文件
syntax = "proto3";

package com.widgets.grpc.api;

message TelemetryRequest {
  string msg = 1;
}

message TelemetryResponse {
  string result = 1;
}

service DeviceService {
  rpc telemetry(TelemetryRequest) returns (stream TelemetryResponse){}
}
# java端proto文件
syntax = "proto3";

option java_multiple_files = false;
option java_package = "com.widgets.grpc.api";
option java_outer_classname = "DeviceProto";

message TelemetryRequest {
  string msg = 1;
}

message TelemetryResponse {
  string result = 1;
}

service DeviceService {
  rpc telemetry(TelemetryRequest) returns (stream TelemetryResponse){}
}

报错原因:两边的package不一致,java端proto文件中没有指定package
修改后:

# nodejs端proto文件
syntax = "proto3";

package com.widgets.grpc.api;

message TelemetryRequest {
  string msg = 1;
}

message TelemetryResponse {
  string result = 1;
}

service DeviceService {
  rpc telemetry(TelemetryRequest) returns (stream TelemetryResponse){}
}
# java端proto文件
syntax = "proto3";

option java_multiple_files = false;
option java_package = "com.widgets.grpc.api";
option java_outer_classname = "DeviceProto";
package com.widgets.grpc.api;

message TelemetryRequest {
  string msg = 1;
}

message TelemetryResponse {
  string result = 1;
}

service DeviceService {
  rpc telemetry(TelemetryRequest) returns (stream TelemetryResponse){}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值