How to communicate gRPC example working with Node.js?

0 votes

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

Dec 5, 2018 in Others by camillelola
• 140 points
141 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,100 points
63 views
0 votes
1 answer

How is machine learning used to detect objects?

To understand the surrounding environment in real ...READ MORE

answered Nov 30, 2018 in Others by Kailash
34 views
0 votes
1 answer

How to get the URL of the current tab in Google Chrome?

There are different ways of doing this:- You ...READ MORE

answered Dec 21, 2018 in Others by Nabarupa
50 views
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
434 views
0 votes
1 answer

How to install C#

Hi @Akanksha, C# is a programming language ...READ MORE

answered Feb 28 in Others by Pratibha
• 2,520 points
21 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
60 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
42 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.