dockerdocker-composefiwaredocker-networkfiware-orion

My dockerized service doesn't receive the notification sent by Orion Context Broker


I don't understand why Orion says to successfully send TrafficFlowObserved entity update but my service (dockerized) receives nothing.

I expect one of the following scenarios:

But neither of these two scenarios happens.

Here's the log from Orion:

2023-01-18 14:16:50 time=Wednesday 18 Jan 13:16:50 2023.790Z | lvl=TMP | corr=N/A | trans=1674046401-299-00000017019 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[564]:httpRequestSendWithCurl | msg=Sending message 16973 to HTTP server: sending message of 994 bytes to HTTP server
2023-01-18 14:16:50 time=Wednesday 18 Jan 13:16:50 2023.792Z | lvl=INFO | corr=N/A | trans=1674046401-299-00000017019 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[587]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://smart-vertical:9090/subscription/traffic-flow/observation?subscriptionId=urn:ngsi-ld:Subscription:59c301f4-972f-11ed-809c-0242ac190006

This is the code of resource in Quarkus that should receive the notification:

@Path("/subscription/traffic-flow")
public class TrafficFlowResource {
    @POST
    @Path("/observation")
    @Consumes(MediaType.APPLICATION_JSON)
    public void measurement(@QueryParam("subscriptionId") String id, Payload payload) {
        logger.info(payload);
    }
}

The Orion Context Broker subscription looks like following, but it's done programmatically:

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
    -H 'Content-Type: application/ld+json' \
    -H 'NGSILD-Tenant: openiot' \
    --data-raw '{
      "description": "Notify me of all traffic flow observation changes",
      "type": "Subscription",
      "entities": [{"type": "TrafficFlowObserved"}],
      "watchedAttributes": [
            "averageVehicleSpeed",
            "intensity",
            "occupancy",
            "levelOfService",
            "roadLoad",
            "saturationFlow"
      ],
      "notification": {
        "format": "keyValues",
        "endpoint": {
          "uri": "http://smart-vertical:9090/subscription/traffic-flow/observation",
          "accept": "application/json"
        }
      },
       "@context": "http://ld-context:80/ngsi-context.jsonld"
    }'

And this is the service configuration in docker:

smart-vertical:
    build:
        context: ./smart-vertical
        dockerfile: src/main/docker/Dockerfile.jvm
    restart: on-failure
    depends_on:
      - orion
    expose:
      - "9090"
    ports:
      - "9090:9090"
    environment:
      - CB_HOST=orion
      - CB_PORT=1026
      - SMART_VERTICAL_PORT=9090
      - SMART_VERTICAL_HOST=http://smart-vertical:9090/subscription
      - NGSI_CONTEXT_URL=http://ld-context:80/ngsi-context.jsonld

Orion and all services are on the same network created automatically by docker.

I have a feeling it's an IP problem but without an error message I can't be sure.

The tests I've done are to change the ip, so instead of using "smart-vertical" in docker-compose.yaml, I've tried "localhost", 172.30.0.8 (set by docker), 0.0.0.0 but the situation gets worse because I get the following results:

2023-01-18 14:55:44 time=Wednesday 18 Jan 13:55:44 2023.079Z | lvl=ERROR | corr=N/A | trans=1674050062-123-00000000379 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[573]:httpRequestSendWithCurl | msg=curl_easy_perform failed: 7

or

2023-01-18 15:07:43 time=Wednesday 18 Jan 14:07:43 2023.747Z | lvl=ERROR | corr=N/A | trans=1674050827-980-00000000194 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[573]:httpRequestSendWithCurl | msg=curl_easy_perform failed: 28

From the Orion implementation (github) I saw that:

Quarkus uses Vertx and by default Vertx uses its own DNS, could this be the problem? But I don't understand why with this setting

SMART_VERTICAL_HOST=http://smart-vertical:9090/subscription

I don't have IP problems but I still don't receive anything.


Solution

  • I confirm it was a network problem. I solved by setting hostname of smart-vertical service and it works! For completeness, below is the part of docker compose affected by the changes:

    smart-vertical:
        build:
            context: ./smart-vertical
            dockerfile: src/main/docker/Dockerfile.jvm
        hostname: smart-vertical