External Task polling failed with EngineError: Response code 404 (Not Found);

Hi,

I have this external task worker which worked fine with Camunda Platform Run. (had an issue - MyBatis - need to downgrade my Java SDK thanks for the help from this forum). But now I am testing the same worker with Camunda in docker and this is the error I get:

polling failed with EngineError: Response code 404 (Not Found); Error: {“path”:“$”,“error”:“resource does not exist”,“code”:“not-found”}; Type: undefined.

The worker code:

const { Client, logger } = require("camunda-external-task-client-js");
const config = { baseUrl: "http://localhost:8055/engine-rest", use: logger };
const client = new Client(config);
client.subscribe("topic-data-collection-a", async function({ task, taskService }) {
  console.log("working on the task");
  await taskService.complete(task);
  console.log("task is completed");
});

Docker compose

bpm-camunda:
    container_name: bpm-camunda
    image: camunda/camunda-bpm-platform:${DISTRO:-latest}
    ports:
      - "8055:8080"
    restart: unless-stopped
    depends_on: 
      - db-postgres
    environment:
      - DB_DRIVER=org.postgresql.Driver
      - DB_URL=jdbc:postgresql://db-postgres:5432/camunda
      - DB_USERNAME=camunda
      - DB_PASSWORD=camunda
      - WAIT_FOR=db-postgres:5432

Note: have to change the port to 8055 as 8080 is used by docker for another product already.

Everything else works fine, deploy, cockpit, rest api. I can get the external tasks from REST API fine
http://localhost:8055/engine-rest/external-task.

What could be the reason for the worker error. Also where can I configure the camunda log when running in docker. (any relevant docs?) (newbie to docker) thanks a lot…

Can somebody help please? I am stuck on this the last couple days. thank you!

Are you able to access the rest api on its own?
Do you get a response if you call

http://localhost:8055/engine-rest/engine

It should return

[{"name":"default"}]

Thanks, Niall!

Yes Calling the API through PostMan is fine

IN postman I can do other things too (start the process, get tasks, get external tasks, complete a task).
It is just not working when doing it from code with the js client.

So i ran the worker locally against my own instance of Camunda Run and it worked correctly.
So there’s something going on with your distribution. Can you give me more details about how you’re strating it and exactly what changes you’ve made to it from the default settings

camunda is running in docker container. I did not make any changes to the camunda image. Below is the docker config in my docker-compose.yml. the image is camunda/camunda-bpm-platform:${DISTRO:-latest}

# Workflow Engine Camunda Container
  bpm-camunda:
    container_name: bpm-camunda
    image: camunda/camunda-bpm-platform:${DISTRO:-latest}
    ports:
      - "8055:8080"
    restart: unless-stopped
    depends_on: 
      - db-postgres
    environment:
      - DB_DRIVER=org.postgresql.Driver
      - DB_URL=jdbc:postgresql://db-postgres:5432/camunda
      - DB_USERNAME=camunda
      - DB_PASSWORD=camunda
      - WAIT_FOR=db-postgres:5432

also the worker works fine with the Camunda platform run (the spring version?)
I also double checked the topic name and it is correct

Should give you the container config for postgres too - the camunda is talking to the postgres in its own container

version: "3.6"
services:
  # Postgres Database Container
  db-postgres:
    container_name: db-postgres
    image: postgres:11.6
    restart: always
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: camunda  
      POSTGRES_PASSWORD: camunda
      POSTGRES_DB: camunda
    volumes:
      - ./volumes/db_postgres_data:/var/lib/postgresql/data
      - ./db-postgres/sql/schema.sql:/docker-entrypoint-initdb.d/0-schema.sql
      - ./db-postgres/sql/insert-data.sql:/docker-entrypoint-initdb.d/1-insert-data.sql
  # Workflow Engine Camunda Container
  bpm-camunda:
    container_name: bpm-camunda
    image: camunda/camunda-bpm-platform:${DISTRO:-latest}
    ports:
      - "8055:8080"
    restart: unless-stopped
    depends_on: 
      - db-postgres
    environment:
      - DB_DRIVER=org.postgresql.Driver
      - DB_URL=jdbc:postgresql://db-postgres:5432/camunda
      - DB_USERNAME=camunda
      - DB_PASSWORD=camunda
      - WAIT_FOR=db-postgres:5432

Just give you more info, this is what I see in cockpit

Awww… that might make a difference alright :slight_smile:

Can you upload the processs model?

Let me do some clean up to remove confidential information. We are in the process of evaluating workflow engine products and this is a POC with our real work flow.

1 Like

I think i know what the problem is. It’s probably going to be solved by ticking async after tick box after both tasks.

With async after checked - it is still the same error.

I had the model cleaned up. How to upload it to this forum?

Sorry for the brutal “upload” I will just post the whole bpmn file here

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0v8frpm" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.8.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="process-ext-task-poc" name="Process External Task POC" isExecutable="true" camunda:versionTag="1.0">
    <bpmn:endEvent id="Event_0j7kora" name="Process Completed">
      <bpmn:extensionElements>
        <camunda:executionListener expression="${execution.setVariable(&#39;milestone&#39;, &#39;complete&#39;)}" event="start" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0kdns9t</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:startEvent id="process-started" name="Process Started">
      <bpmn:extensionElements>
        <camunda:executionListener expression="${execution.setVariable(&#39;milestone&#39;, &#39;data-collection&#39;)}" event="end" />
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_0ii1ljc</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_0ii1ljc" sourceRef="process-started" targetRef="data-collection" />
    <bpmn:subProcess id="data-collection" name="Data Collection">
      <bpmn:incoming>Flow_0ii1ljc</bpmn:incoming>
      <bpmn:outgoing>Flow_0kdns9t</bpmn:outgoing>
      <bpmn:startEvent id="Event_0msp1a3">
        <bpmn:outgoing>Flow_1g9uq6a</bpmn:outgoing>
      </bpmn:startEvent>
      <bpmn:endEvent id="Event_18al1j4">
        <bpmn:incoming>Flow_1207fe2</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:parallelGateway id="Gateway_1b12uf3">
        <bpmn:incoming>Flow_1g9uq6a</bpmn:incoming>
        <bpmn:outgoing>Flow_0v6omwz</bpmn:outgoing>
        <bpmn:outgoing>Flow_1r3v3zl</bpmn:outgoing>
      </bpmn:parallelGateway>
      <bpmn:sequenceFlow id="Flow_1g9uq6a" sourceRef="Event_0msp1a3" targetRef="Gateway_1b12uf3" />
      <bpmn:sequenceFlow id="Flow_0v6omwz" sourceRef="Gateway_1b12uf3" targetRef="data-collection-a" />
      <bpmn:sequenceFlow id="Flow_1r3v3zl" sourceRef="Gateway_1b12uf3" targetRef="data-collection-b" />
      <bpmn:parallelGateway id="Gateway_0629pey" camunda:asyncAfter="true" camunda:exclusive="false">
        <bpmn:incoming>Flow_1vpl4yo</bpmn:incoming>
        <bpmn:incoming>Flow_0smoxpw</bpmn:incoming>
        <bpmn:outgoing>Flow_1207fe2</bpmn:outgoing>
      </bpmn:parallelGateway>
      <bpmn:sequenceFlow id="Flow_1vpl4yo" sourceRef="data-collection-a" targetRef="Gateway_0629pey" />
      <bpmn:sequenceFlow id="Flow_0smoxpw" sourceRef="data-collection-b" targetRef="Gateway_0629pey" />
      <bpmn:sequenceFlow id="Flow_1207fe2" sourceRef="Gateway_0629pey" targetRef="Event_18al1j4" />
      <bpmn:userTask id="data-collection-b" name="Data Collection B">
        <bpmn:incoming>Flow_1r3v3zl</bpmn:incoming>
        <bpmn:outgoing>Flow_0smoxpw</bpmn:outgoing>
      </bpmn:userTask>
      <bpmn:serviceTask id="data-collection-a" name="Data Collection A" camunda:type="external" camunda:topic="topic-data-collection-a">
        <bpmn:incoming>Flow_0v6omwz</bpmn:incoming>
        <bpmn:outgoing>Flow_1vpl4yo</bpmn:outgoing>
      </bpmn:serviceTask>
    </bpmn:subProcess>
    <bpmn:sequenceFlow id="Flow_0kdns9t" sourceRef="data-collection" targetRef="Event_0j7kora" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process-ext-task-poc">
      <bpmndi:BPMNEdge id="Flow_0ii1ljc_di" bpmnElement="Flow_0ii1ljc">
        <di:waypoint x="218" y="200" />
        <di:waypoint x="320" y="200" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0kdns9t_di" bpmnElement="Flow_0kdns9t">
        <di:waypoint x="860" y="240" />
        <di:waypoint x="922" y="240" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="process-started">
        <dc:Bounds x="182" y="182" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="163" y="225" width="79" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0j7kora_di" bpmnElement="Event_0j7kora">
        <dc:Bounds x="922" y="222" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="913" y="265" width="54" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0lfirh1_di" bpmnElement="data-collection" isExpanded="true">
        <dc:Bounds x="320" y="40" width="540" height="360" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1207fe2_di" bpmnElement="Flow_1207fe2">
        <di:waypoint x="745" y="240" />
        <di:waypoint x="779" y="240" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0smoxpw_di" bpmnElement="Flow_0smoxpw">
        <di:waypoint x="630" y="310" />
        <di:waypoint x="720" y="310" />
        <di:waypoint x="720" y="265" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1vpl4yo_di" bpmnElement="Flow_1vpl4yo">
        <di:waypoint x="640" y="140" />
        <di:waypoint x="720" y="140" />
        <di:waypoint x="720" y="215" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1r3v3zl_di" bpmnElement="Flow_1r3v3zl">
        <di:waypoint x="440" y="270" />
        <di:waypoint x="440" y="310" />
        <di:waypoint x="530" y="310" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0v6omwz_di" bpmnElement="Flow_0v6omwz">
        <di:waypoint x="440" y="215" />
        <di:waypoint x="440" y="140" />
        <di:waypoint x="540" y="140" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1g9uq6a_di" bpmnElement="Flow_1g9uq6a">
        <di:waypoint x="380" y="240" />
        <di:waypoint x="415" y="240" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_0msp1a3_di" bpmnElement="Event_0msp1a3">
        <dc:Bounds x="344" y="222" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_18al1j4_di" bpmnElement="Event_18al1j4">
        <dc:Bounds x="779" y="222" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_0whl7lz_di" bpmnElement="Gateway_1b12uf3">
        <dc:Bounds x="415" y="215" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gateway_1e4b8ti_di" bpmnElement="Gateway_0629pey">
        <dc:Bounds x="695" y="215" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1hu24ae_di" bpmnElement="data-collection-b">
        <dc:Bounds x="530" y="270" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1c4rcpj_di" bpmnElement="data-collection-a">
        <dc:Bounds x="540" y="100" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

I do get the external task via postman. the js client is a wrapper around this (and other) API call I assume? Could it be it is not compatible with whatever the image the container is using - just a wild guess.

HI @Rockdale
Sorry for the delay in getting back to you.
So -I have bad news that might in any other situation sound like good news… I deployed your process and ran the worker and everything worked perfectly on my machine.

The only difference with how i ran it is that I didn’t use Docker (I used the regular Camunda Run distro) and i used all the default engine settings including port 8080.

If there anything else that might be going on with your setup?

Thanks Niall.

Camunda Run Distro works for me too. But it does not work with docker. I can try docker with default port 8080 to see how it goes. Do you know with docker, how can I config the Camunda log so I can see the error on the server side - that might give me some clues what went wrong? Again, thank you.

Hi, @Niall

Just tried, It works with port 8080.

  bpm-camunda:
    container_name: bpm-camunda
    image: camunda/camunda-bpm-platform:${DISTRO:-latest}
    ports:
      - "8080:8080"
    restart: unless-stopped
    depends_on: 
      - db-postgres
    environment:
      - DB_DRIVER=org.postgresql.Driver
      - DB_URL=jdbc:postgresql://db-postgres:5432/camunda
      - DB_USERNAME=camunda
      - DB_PASSWORD=camunda
      - WAIT_FOR=db-postgres:5432

Seems the client did not take in the config when port was 8055? I will look into the camunda-external-task-client-js source code to see if the configured value is overwritten by default value (8080)

Not sure what happened but it is working now with docker and port 8055.

Once I have it working with 8080 I stopped everything and change it back to 8055 and now it is working.

Thanks @Niall for all your help.

1 Like

Very happy to hear that it’s working now.