Use dgraph-js on Cloud multi-tenancy environment

When testing with a shared instance we’ve been using the clientStubFromCloudEndpoint method with the client API key and that worked perfectly.

Now we want to test to use dgraph-js client to connect to a multi-tenancy instance.

I want to avoid using the loginIntoNamespace() method since login mutation was already called using the GraphQL endpoint.
So we are using the DgraphClientStub instead of clientStubFromCloudEndpoint.

I would like to pass the accessToken and refreshToken to the clientStub. Is that something that can be done ?

const clientStub = new dgraph.DgraphClientStub(

dgraphClientStub.accessJwt = dgraphAccessToken;
dgraphClientStub.refreshJwt = dgraphRefreshToken;

Getting this error:
Error: 14 UNAVAILABLE: read ECONNRESET at Object.callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:31:26) at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client.js:179:52) at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141) at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181) at /app/node_modules/@grpc/grpc-js/build/src/call-stream.js:145:78 at processTicksAndRejections (internal/process/task_queues.js:79:11) {
2021-08-11 13:13:50 dgraph-custom-backend[20210811t100522] code: 14,
2021-08-11 13:13:50 dgraph-custom-backend[20210811t100522] details: ‘read ECONNRESET’,
2021-08-11 13:13:50 dgraph-custom-backend[20210811t100522] metadata: Metadata { internalRepr: Map {}, options: {} }
2021-08-11 13:13:50 dgraph-custom-backend[20210811t100522] }


Report a Dgraph Client Bug

What Dgraph client (and version) are you using?

(put “x” in the box to select)

  • Dgo
  • PyDgraph
  • Dgraph4J
  • Dgraph-js X
  • Dgraph-js-http
  • Dgraph.NET


What version of Dgraph are you using?

Cloud dedicated instance

Have you tried reproducing the issue with the latest release?


What is the hardware spec (RAM, OS)?


Steps to reproduce the issue (command/config used to run Dgraph).

Expected behaviour and actual result.

Experience Report for Feature Request

Note: Feature requests are judged based on user experience and modeled on Go Experience Reports. These reports should focus on the problems: they should not focus on and need not propose solutions.

What you wanted to do

What you actually did

Why that wasn’t great, with examples

Any external references to support your case

Hi Anibal,
Using the loginIntoNamespace method available on the Dgraph Client is the recommended way to connect to a multi-tenant backend. Access tokens are short lived and they do expire. Dgraph client manages the token lifecycle, including detecting expiry and regeneration of token.