Hi Guys,
I am working as a Node.js developer. I am trying to understand how to communicate with a gRPC server. It seems I have to load any .proto files you provided and load protoDescriptor to work with the client.
Actually, with the example below am not able to load proto files because proto-loader mess up with Google APIs importing.
var PROTO_PATH = __dirname + '/../protos/';
var grpc = require('grpc');
var protoLoader = require('@grpc/proto-loader');
console.log(PROTO_PATH);
var packageDefinition = protoLoader.loadSync(PROTO_PATH + 'internal.proto');
console.log(packageDefinition);
//PROTO_PATH);
//{keepCase: true,
// longs: String,
// enums: String,
// defaults: true,
// oneofs: true
//});
var protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
// The protoDescriptor object has the full package hierarchy
var api_proto = protoDescriptor.api;
console.log(api_proto);
function main() {
var client = new api_proto.InternalService('192.168.1.80:8080',
grpc.credentials.createInsecure());
var body = JSON.stringify({ username: "admin", password: "password" })
client.Login({}, function(err, response) {
console.log('loginresponse:', response.message);
});
}
main();
Would be great if you can provide an example that can work with Lora-app-server gRPC.
Thanks & Regards
Camillelola