Unable to connect to server

Moved from GitHub dgraph-js/49

Posted by avishwakarma:

I am not able to connect to dgraph using dgraph-js

var clientStub = dgraph.DgraphClientStub(
   ‘127.0.0.1:9080’, // tried all other ports 5080 7080 8080
   grpc.credentials.createInsecure()
 );
var client = dgraph.DgraphClient(clientStub);

console.log(clientStub) // undefined
console.log(client) // undefined

Executed the below commands and dgraph-ratel is working fine

dgraph zero

dgraph alpha --lru_mb 2048 --zero localhost:5080

dgraph-ratel

My dgraph-ratel is connected on localhost:8080

Any idea what I have missed?

danielmai commented :

Looks alright to me. Is that your full source?

Here’s what I ran, which is essentially identical to what you did:

const dgraph = require("dgraph-js");
const grpc = require("grpc");

const clientStub = new dgraph.DgraphClientStub(
    "127.0.0.1:9080",
    grpc.credentials.createInsecure(),
);
const client = new dgraph.DgraphClient(clientStub);

console.log(clientStub);
console.log(client);

Output (not undefined):

DgraphClientStub {
  stub:
   ServiceClient {
     '$interceptors': [],
     '$interceptor_providers': [],
     '$callInvocationTransformer': undefined,
     '$channel': Channel {} },
  promisified:
   { alter: [Function],
     query: [Function],
     mutate: [Function],
     commitOrAbort: [Function],
     checkVersion: [Function],
     waitForReady: [Function] } }
DgraphClient {
  debugMode: false,
  clients:
   [ DgraphClientStub { stub: [ServiceClient], promisified: [Object] } ],
  linRead:
   { wrappers_: null,
     messageId_: undefined,
     arrayIndexOffset_: -1,
     array: [],
     pivot_: 1.7976931348623157e+308,
     convertedFloatingPointFields_: {} } }

paulftw commented :

I’m closing this issue due to inactivity and also because we cannot reproduce the problem.
Please provide more details in Forums http://discuss.dgraph.io and once it’s confirmed to be a bug with the library please do reopen this or create another issue