urb
urb

Reputation: 964

Orion doesn't notify Cygnus

I followed the official documentation about cygnus and orion. All generic enablers are deployed correctly, without errors in their log files. But something strange happens, Orion never notifies Cygnus.

To test this mechanism I followed the example with Car entity provided in the official documentation.

My entity creation bash script:

(curl $1:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
  "contextElements": [
    {
      "type": "Car",
      "isPattern": "false",
      "id": "Car1",
      "attributes": [
      {
        "name": "speed",
        "type": "integer",
        "value": "75"
      },
      {
        "name": "fuel",
        "type": "float",
        "value": "12.5"
      }
      ]
    }
  ],
  "updateAction": "APPEND"
}
EOF

My entity subscription bash script:

(curl $1:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: vehicles' --header 'Fiware-ServicePath: /4wheels' -d @- | python -mjson.tool) <<EOF
{
    "entities": [
        {
            "type": "Car",
            "isPattern": "false",
            "id": "Car1"
        }
    ],
    "attributes": [
        "speed",
        "oil_level"
    ],
    "reference": "http://$2:5050/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "speed"
            ]
        }
    ],
    "throttling": "PT1S"
}
EOF

My entity update bash script:

(curl $1:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
  "contextElements": [
    {
      "type": "Car",
      "isPattern": "false",
      "id": "Car1",
      "attributes": [
      {
        "name": "speed",
        "type": "integer",
        "value": $2
      }
      ]
    }
  ],
  "updateAction": "UPDATE"
}
EOF

Note: Orion responds to all requests.

After executing these scripts, cygnus must receive reported information from orion and save it in the database, but nothing happens. Neither in /var/log/cygnus/cygnus.log file or in /var/log/contextBroker/contextBroker.log file are reported any information about orion notification.

Note: If I use the notify.sh script provided in the official documentation, Cygnus works well and saves all data in the database.

Note: I read in other questions problems about open ports but those don't apply to mine.

EDIT 1

After I subscribe the orion, the response is:

{
    "subscribeResponse": {
        "duration": "P1M",
        "subscriptionId": "563e12b4f4d8334d599753e0",
        "throttling": "PT1S"
    }
}

And when I update anentity, orion returns it:

{
    "contextResponses": [
        {
            "contextElement": {
                "attributes": [
                    {
                        "name": "speed",
                        "type": "integer",
                        "value": ""
                    }
                ],
                "id": "Car1",
                "isPattern": "false",
                "type": "Car"
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}

To GET entity from orion I used the following script:

(curl $1:1026/v1/queryContext -s -S --header 'Content-Type: application/json' \
    --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
    "entities": [
        {
            "type": "Car",
            "isPattern": "false",
            "id": "Car1"
        }
    ]
} 
EOF

Response:

{
    "contextResponses": [
        {
            "contextElement": {
                "attributes": [
                    {
                        "name": "fuel",
                        "type": "float",
                        "value": "12.5"
                    },
                    {
                        "name": "speed",
                        "type": "integer",
                        "value": "123"
                    }
                ],
                "id": "Car1",
                "isPattern": "false",
                "type": "Car"
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}

Note The speed value was updated with success.

Upvotes: 2

Views: 207

Answers (1)

fgalan
fgalan

Reputation: 12294

Taking into account the Fiware-Service and Fiware-ServicePath headers in subscription request, it has been performeed in the "/4wheels" service path of the service "vehicles". However, entity creation request doesn't use such headers, so it is created in the default service path ("/") of the default service. Thus, the subscription is not "covering" the entity, so updates in the entity are not triggering notifications.

One solution to the problem would be to create the entity in the same service and service path of the subscription, i.e. "/4wheels" service path of the service "vehicles".

Please, check Orion official documentation about service and service path concepts.

Upvotes: 1

Related Questions