Node.js gRPC Connection with tool proto file

104
January 10, 2020, at 11:10 PM

I am trying to create a Node.js gRPC connection with a tool I am running on my machine called Pachyderm. I generated a .proto file for the tool, which will simply display the version of the tool. I have generated a server.js for it, however, it is not successfully pulling the tool version by connecting to the respective IP:port of the tool.

If you could help me troubleshoot this, I would greatly appreciate it.

.proto file

syntax = "proto3";
import "google/protobuf/empty.proto";
package versionpb;
option go_package = "github.com/pachyderm/pachyderm/src/client/version/versionpb";
message Version {
  uint32 major = 1;
  uint32 minor = 2;
  uint32 micro = 3;
  string additional = 4;
}
service API {
  rpc GetVersion(google.protobuf.Empty) returns (Version) {}
}

server.js

const path = require('path')
const protoLoader = require('@grpc/proto-loader')
const grpc = require('grpc')
const PROTO_PATH = path.resolve(__dirname, './protos/pach.proto')
const pd = protoLoader.loadSync(PROTO_PATH)
const hp = grpc.loadPackageDefinition(pd).pach
function sayHello (call, fn) {
  fn(null, { message: 'The tool version is ' + call.request.name })
}
function main () {
  const port = 30650
  const server = new grpc.Server()

  server.bind(`192.161.5.3:${port}`, grpc.ServerCredentials.createInsecure())
  server.start()
  console.log(`gRPC server started on port: ${port}`)
}
main()
READ ALSO
Where do NodeJs files go in a Linux container?

Where do NodeJs files go in a Linux container?

I am trying to setup a container for my nodejs applicationI am doing a multistage dockerfile and have the builder part done

84
Preventing SQL injection in Node.js

Preventing SQL injection in Node.js

Is it possible to prevent SQL injections in Nodejs (preferably with a module) in the same way that PHP had Prepared Statements that protected against them

111
Define a string variable in a NodeJS file by fetching the Nth line from a local text file?

Define a string variable in a NodeJS file by fetching the Nth line from a local text file?

I have the following script (shown below shortened and excerpted with only the relevant segments) using Nodemailer for NodeJS to e-mail the results of a daily AV scan with a variety of system information embedded

78