Zeebe Node can't connect client to camunda cloud

I read that you can connect a Zeebe client to Camunda Cloud like so

const zbc = new ZBClient({
  camundaCloud: {
    clientId: 'yStuGvJ6a1RQhy8DQpeXJ80yEpar3pXh',
    clientSecret: 'WZahIGHjyj0-oQ7DZ_aH2wwNuZt5O8Sq0ZJTz0OaxfO7D6jaDBZxM_Q-BHRsiGO_',
    clusterId: '103ca930-6da6-4df7-aa97-941eb1f85040',
    cacheDir: './tokens'
  }
})

However, trying this with my own credentials which I copied from https://console.cloud.camunda.io/, the connection always has an error. I know that sometimes the error message is premature, from the Initial Connection Tolerance section of the npm package readme, but even after 20 seconds it still has an error. The zbc object I create has logger.state === 'ERROR'

Am I doing something wrong?

Hi @Harry_Lowson and welcome to the Camunda Community!

Just to verify, try doing the following:

From your terminal (assuming *nix, macOS)

% export ZEEBE_ADDRESS=YOUR_ZEEBE_CLUSTER_ADDRESS
% export ZEEBE_CLIENT_ID=YOUR_ZEEBE_CLIENT_ID
% export ZEEBE_CLIENT_SECRET=YOUR_ZEEBE_SECRET

to set the environment variables. for those. Once that’s done, in your code you should be able to simply use

const zbc = new ZBClient();

And the new client will get the proper credentials from the env variables you set.

If that works, then we can try to debug why setting them explicitly is failing.

Best Regards,
dg

1 Like

This works for me:

const {ZBClient} = require('zeebe-node')

async function main() {
    const zb = new ZBClient({
        camundaCloud: {
          clientId: 'OUg3pCd0Z_...',
          clientSecret: 'Jk.h7fDtb1A...',
          clusterId: 'd76914f0-dcd0-...',
          cacheDir: './tokens'
        }
      })
    console.log(await zb.topology())
}

main()

Output:

➜ node index.js     
14:40:47.102 | zeebe |  INFO: Authenticating client with Camunda Cloud...
14:40:49.076 | zeebe |  INFO: Established encrypted connection to Camunda Cloud.
{
  brokers: [
    {
      partitions: [Array],
      nodeId: 0,
      host: 'zeebe-0.zeebe-broker-service.d76914f0-dcd0-4074-8547-567cf2e4f66c-zeebe.svc.cluster.local',
      port: 26501,
      version: '8.0.1'
    },
    {
      partitions: [Array],
      nodeId: 2,
      host: 'zeebe-2.zeebe-broker-service.d76914f0-dcd0-4074-8547-567cf2e4f66c-zeebe.svc.cluster.local',
      port: 26501,
      version: '8.0.1'
    },
    {
      partitions: [Array],
      nodeId: 1,
      host: 'zeebe-1.zeebe-broker-service.d76914f0-dcd0-4074-8547-567cf2e4f66c-zeebe.svc.cluster.local',
      port: 26501,
      version: '8.0.1'
    }
  ],
  clusterSize: 3,
  partitionsCount: 2,
  replicationFactor: 3,
  gatewayVersion: '8.0.1'
}

Package.json:

  "dependencies": {
    "zeebe-node": "^8.0.1"
  }