Details
- 
        Type:Monitor 
- 
        Status: Closed
- 
            Priority: Major Major
- 
            Resolution: Done
- 
            Affects Version/s: None
- 
            Fix Version/s: 2021
- 
            Component/s: FIWARE-TECH-HELP
- 
            Labels:
- 
                        HD-Chapter:Data
- 
                        HD-Enabler:Orion
Description
Created question in FIWARE Q/A platform on 27-01-2017 at 15:01
Please, ANSWER this question AT http://stackoverflow.com/questions/41895831/fiware-orion-context-broker-subscription-v1-conditions-was-supposed-to-be-an
Question:
Fiware - Orion Context Broker subscription V1, "conditions was supposed to be an array"
Description:
When trying to use STH to be able to store and retrieve data sent to OCB, I have a problem making the subscription.
My problem is that the subscription creation goes well.
When I create the subscription as following:
POST /v1/contextSubscriptions HTTP/1.1
Host: <cb_host>:1026
Content-Type: application/json
Fiware-Service: myService
Fiware-ServicePath: /myServicePath
Cache-Control: no-cache
{
  "entities": [
  ],
  "attributes": [ 
    "class" 
    ],
  "reference": "http://<cb_host>:8666/notify",
  "duration": "P1M",
  "notifyConditions": [
  ],
    "throttling": "PT5S"
}
I receive following answer:
{
  "subscribeResponse": 
}
but on the Fiware server, i see an error about the conditions in the terminal running the containers, and another one about the attributes:
orion | ERROR@14:06:10 safeMongo.cpp[302]: Runtime Error (field 'conditions' was supposed to be an array but type=4 in BSONObj <{ _id: ObjectId('588b4f96e2066a50fa98df9c'), expiration: 1488116886, reference: "http://<cb_host>:8666/notify", custom: false, throttling: 5, servicePath: "/myServicePath", status: "active", entities: [
{ id: "sensor03", isPattern: "true", type: "cameraSimple", isTypePattern: false }], attrs: [ "class" ], metadata: [], blacklist: false, conditions: [ "class" ], expression:
{ q: "", mq: "", geometry: "", coords: "", georel: "" }, format: "JSON" }> from caller mongoSubCacheItemInsert:221)
orion               | ERROR@13:48:10  safeMongo.cpp[302]: Runtime Error (field 'attrs' was supposed to be an array but type=4 in BSONObj <{ _id: ObjectId('588b4f96e2066a50fa98df9c'), expiration: 1488116886, reference: "http://<cb_host>:8666/notify", custom: false, throttling: 5, servicePath: "/myServicePath", status: "active", entities: [ 
], attrs: [ "class" ], metadata: [], blacklist: false, conditions: [ "class" ], expression:
{ q: "", mq: "", geometry: "", coords: "", georel: "" }, format: "JSON" }> from caller mongoSubCacheItemInsert:215)
Also, when updating a value on my entity,
PUT /v2/entities/sensor03/attrs/class/value HTTP/1.1
Host: <cb_host>:1026
Accept: application/json
Fiware-Service: myService
Fiware-ServicePath: /myServicePath
Cache-Control: no-cache
"monitor"
I get nothing when querying the STH:
GET /STH/v1/contextEntities/type/myDevice/id/sensor03/attributes/class?lastN=10 HTTP/1.1
Host: <cb_host>:8666
Accept: application/json
Fiware-Service: myService
Fiware-ServicePath: /myServicePath
Cache-Control: no-cache
returns:
{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
        ],
        "id": "sensor03",
        "isPattern": false,
        "type": "myDevice"
      },
      "statusCode": 
    }
  ]
}
Note:
I use NGSI V1, as I suspect V2 is not yet supported for STH receiving NGSI V2 notifications regarding this issue. 
Also i didn't find any documentation regarding "Getting historical raw context information" with NGSI V2, e.g on this page
I use Docker-machine with a singl debian 8 VM running on Fiware-Lab with following images:
mongodb:
    image: mongo:2.6
    hostname: mongodb
    container_name: mongodb
    command: --smallfiles
orion:
    image: fiware/orion:develop
    hostname: orion
    container_name: orion
    links:
- mongodb
 expose:
- "1026"
 ports:
- "1026:1026"
 command: -dbhost mongodb
fiware-sth-comet:   
    image: telefonicaiot/fiware-sth-comet   
    links:
- mongodb
 ports:
- "8666:8666"
 environment:
- STH_HOST=0.0.0.0
- DB_URI=mongodb:27017
2017-01-30 18:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False