/c8-sdk-demo/node_modules/got/dist/source/as-promise/index.js:118
request._beforeError(new types_1.HTTPError(response));
^
HTTPError: Response code 401 (Unauthorized)
at Request.<anonymous> (/c8-sdk-demo/node_modules/got/dist/source/as-promise/index.js:118:42)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1705712511411,
socket: 1705712511412,
lookup: 1705712511442,
connect: 1705712511453,
secureConnect: 1705712511470,
upload: 1705712511470,
response: 1705712511800,
end: 1705712511801,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 30,
tcp: 11,
tls: 17,
request: 0,
firstByte: 330,
download: 1,
total: 390
}
}
}
Hi @praveenc, welcome to the forums! What is your question? Are you using SaaS or Self Managed? Did you set up your client credentials for API access? How have you configured the client? We need a lot more detail to be able to assist!
- The code to create Zeebe Worker is erroring out with authorized request.
- Using SaaS versions
- Client credentials for API access are set-up
- Using the Node sdk https://camunda.com/blog/2023/05/unified-camunda-8-sdk-nodejs/#h.qv4s3po08q8p
/c8-sdk-demo/nod**e_modules/got/dist/source/as-promise/index.js:118**
** request._beforeError(new types_1.HTTPError(response));**
** ^**
HTTPError: Response code 401 (Unauthorized)
at Request.<anonymous> (/c8-sdk-demo/node_modules/got/dist/source/as-promise/index.js:118:42)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1705712511411,
socket: 1705712511412,
lookup: 1705712511442,
connect: 1705712511453,
secureConnect: 1705712511470,
upload: 1705712511470,
response: 1705712511800,
end: 1705712511801,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 30,
tcp: 11,
tls: 17,
request: 0,
firstByte: 330,
download: 1,
total: 390
}
}
}
- The code to create Zeebe Worker is erroring out with authorized request.
- Using SaaS versions
- Client credentials for API access are set-up
- Using the Node sdk https://camunda.com/blog/2023/05/unified-camunda-8-sdk-nodejs/#h.qv4s3po08q8p
@praveenc - what version of the Node Zeebe client are you using? What permissions have you assigned to in Console? How are you initializing the Zeebe client in your code?
From package.json
“license”: “ISC”,
“dependencies”: {
“camunda-8-sdk”: “^0.15.0”,
“dotenv”: “^16.3.1”,
“typescript”: “^5.3.3”
},
“devDependencies”: {
“ts-node”: “^10.9.2”
I don’t know how to check for the Zeebe client verion. I have assigned:
From the Camunda console the API key scopes are as follows
Cluster scopes: Get, Create, Delete
Connector secret scopes:Get, Create, Delete
Modeler scopes:Get, Create, Delete, Update
Tried the below option
zb.createWorker({
taskType: ‘SendEmail’,
taskHandler: function (job: { complete: () => any }) {
console.log(‘Entering send email’)
//const {message_content} = job.variables
//worker.log(‘Sending email from Email Service’ )
var myHeaders = new Headers()
Thanks
@praveenc - looks like you might be missing a permission on the API key. In Console, you need to add Zeebe as a scope as well.
Hi @praveenc - it looks like you are using the wrong set of client credentials. That screenshot is from the Console → Organizations management page; to access your processes, you need to create a credential inside the cluster. (Console → Clusters → select your cluster → API). This page should help you get started:
Thank you very much Nathan. I think I am able to connect to Zeebe. Though, the code does not console log the zb.topology(), there is message that connecting to Camunda cloud. Any pointers on how to fix the grpc issue ?
const zb = new ZBClient({
camundaCloud: {
clientId: ‘xt’,
clientSecret: ‘n’,
clusterId: ‘14’,
audience:‘api.cloud.camunda.io’,
url:‘https://login.cloud.camunda.io/oauth/token’
}
})
try{
// console.log(await zb.topology())
console.log('Zb client created')
console.log(`Creating worker...`)
const res1 = await zb.topology()
ZBClient.
res1.header("Content-Type", "application/grpc");
//console.log(JSON.stringify(res1, null, 2))
}catch(e) {
console.log(e)
}
throws grpc error. Based on package.json,
@grpc/grpc-js": “1.9.7”,
“@grpc/proto-loader”: “0.7.10”,
@praveenc - that looks like a network error. Are you behind a proxy or firewall perhaps?
Firewall does not seems to be the issue. Attached is the screen shot. The connection to Camunda Cloud is successful.
Any other pointers ?
@praveenc - in my experience, that is a network-related issue. gRPC uses HTTP/2 so you need to make sure you are allowing HTTP/2 inbound through any firewalls and proxies.
Can you try to connect using the zbctl client? That will eliminate your code and its dependencies as the issue (or it will show that the issue is not networking).
Using Camunda managed solution.
@praveenc - when using SaaS, when you create client credentials there is an option to download the variables as a text file:
I did. The text file has 4 parameter but not IP address
zeebe.client.cloud.region=ont-1
zeebe.client.cloud.clusterId=144
zeebe.client.cloud.clientId=xt1
zeebe.client.cloud.clientSecret=
@praveenc - you need to toggle over to the “Env Vars” tab. (This is also a fake screenshot, those are not valid ID’s or secrets!)