fiwarefiware-orionfiware-sth-comet

Unable to create the STH context broker subscription


I'm using the master branch of the sth-comet's github repo (currently a prerelease of 2.0.0-next) and I am able to install and execute it. The problem appears when I want to create the subscription on the context broker (v1.4.0). Both services are installed in the same FIWARE Lab machine and I accessing them remotely using a public IP address.

I've been trying to create the subscription using the template provided in your documentation, but the STH is always complaining about the FIWARE-Service and the FIWARE-ServicePath headers (seems the context broker is not sending them along the notifications). This is the command for creating the subscription:

curl http://$(server):1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -H 'FIWARE-Service: default' -H 'FIWARE-ServicePath: /' -d @- <<EOF
{
    "entities": [
        {
            "type": "weather.station",
            "isPattern": "true",
            "id": ".*"
        }
    ],
    "attributes": [
        "temperature",
        "humidity"
    ],
    "reference": "http://$(server):8666/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "temperature",
                "humidity"
            ]
        }
    ],
    "throttling": "PT5S"
}
EOF

This is the reported error:

time=2016-10-06T15:56:30.124Z | lvl=WARN | corr=7220efae-8bdd-11e6-96a8-fa163ea89c59 | trans=11ef935c-f749-46b7-bcd4-942ffddedd27 | op=OPER_STH_POST | srv=default | subsrv=n/a | msg=POST /notify, event={"request":"1475769390111:robots:23181:ityixskh:10000","timestamp":1475769390123,"tags":["validation","error","headers"],"data":{"data":{"data":null,"isBoom":true,"isServer":false,"output":{"statusCode":400,"payload":{"statusCode":400,"error":"Bad Request","message":"child \"fiware-servicepath\" fails because [fiware-servicepath is required]"},"headers":{}}},"isBoom":true,"isServer":false,"output":{"statusCode":400,"payload":{"statusCode":400,"error":"Bad Request","message":"child \"fiware-servicepath\" fails because [fiware-servicepath is required]","validation":{"source":"headers","keys":[]}},"headers":{}}},"internal":true}

If I use v2 of the context broker API, I'm able to force it to send the FIWARE-Service and FIWARE-ServicePath headers:

curl http://$(server):1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -H 'FIWARE-Service: default' -H 'FIWARE-ServicePath: /' -d @- <<EOF
{
    "description": "STH subscription",
    "subject": {
        "entities": [
            {
                "type": "weather.station",
                "idPattern": ".*"
            }
        ],
        "condition": {  
            "attrs":[  
                "temperature",
                "humidity"
            ]
        }
    },
    "notification": {
        "httpCustom": {
            "url": "http://$(server):8666/notify",
            "headers": {
                "FIWARE-Service": "default",
                "FIWARE-ServicePath": "/"
            }
        },
        "attrs": [
            "temperature",
            "humidity"
        ]
    },
    "expires": "2018-04-05T14:00:00.00Z",
    "throttling": 5
}
EOF

This way, the STH server does not compliant about the headers, although it raises other errors:

time=2016-10-06T15:46:57.564Z | lvl=ERROR | corr=19e59f02-8bdc-11e6-8534-fa163ea89c59 | trans=1b7fc29a-7f5c-449d-9238-d2e644154b05 | op=OPER_STH_POST | srv=default | subsrv=/ | msg=POST /notify, event={"request":"1475768812582:robots:8985:itycaq0o:10003","timestamp":1475768817564,"tags":["request","closed","error"],"internal":true}
time=2016-10-06T15:47:02.592Z | lvl=ERROR | corr=19e59f02-8bdc-11e6-8534-fa163ea89c59 | trans=7e5bf417-0b1d-4b53-b47b-838cead91b94 | op=OPER_STH_POST | srv=default | subsrv=/ | msg=POST /notify, event={"request":"1475768817606:robots:8985:itycaq0o:10004","timestamp":1475768822592,"tags":["request","closed","error"],"internal":true}

Solution

  • First off, thank you very much for using the STH component ;)

    It seems the issue is related to the Orion Context Broker not including the Fiware-ServicePath header in the notifications sent to the STH component if the service path is the empty or default one (i.e., /). I just created an issue to deal with it in the Orion Context Broker repository in case you also want to track it: https://github.com/telefonicaid/fiware-orion/issues/2584

    If you use any other valid service path, everything should be fine.

    Thank you very much once again!

    Best, Germán.