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(
   ‘’, // tried all other ports 5080 7080 8080
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


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(
const client = new dgraph.DgraphClient(clientStub);


Output (not undefined):

DgraphClientStub {
   ServiceClient {
     '$interceptors': [],
     '$interceptor_providers': [],
     '$callInvocationTransformer': undefined,
     '$channel': Channel {} },
   { alter: [Function],
     query: [Function],
     mutate: [Function],
     commitOrAbort: [Function],
     checkVersion: [Function],
     waitForReady: [Function] } }
DgraphClient {
  debugMode: false,
   [ DgraphClientStub { stub: [ServiceClient], promisified: [Object] } ],
   { 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