簡體   English   中英

Fiware - Orion Context Broker訂閱未發送到STH,“條件應該是一個數組”

[英]Fiware - Orion Context Broker subscription not sent to STH, “conditions was supposed to be an array”

當嘗試使用STH來存儲和檢索發送到OCB的數據時,我在進行訂閱時遇到問題。

我的問題是訂閱創建順利。 當我按以下方式創建訂閱時:

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": [
    {
      "type": "cameraSimple",
      "isPattern": "true",
      "id": "sensor03"
    }
  ],
  "attributes": [ 
    "class" 
    ],
  "reference": "http://<cb_host>:8666/notify",
  "duration": "P1M",
  "notifyConditions": [
    {
      "type": "ONCHANGE",
      "condValues": [
        "class"
        ]
    }
  ],
    "throttling": "PT5S"
}

我收到以下答案:

{
  "subscribeResponse": {
    "subscriptionId": "588b4f38e2066a50fa98df9b",
    "duration": "P1M",
    "throttling": "PT5S"
  }
}

但是在Fiware服務器上,我看到有關運行容器的終端中的條件的錯誤,以及有關屬性的另一個錯誤:

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: [ { 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:215)

此外,在更新我的實體上的值時,

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"

在查詢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

收益:

{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "class",
            "values": []
          }
        ],
        "id": "sensor03",
        "isPattern": false,
        "type": "myDevice"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

注意:

  • 我使用NGSI V1,因為我懷疑STH尚未支持V2接收有關此問題的 NGSI V2通知。 此外,我沒有找到任何與NGSI V2“獲取歷史原始上下文信息”的文檔,例如在此頁面上
  • 我使用Docker-machine和在Fiware-Lab上運行的單個Debian 8 VM,其中包含以下圖像:

     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 

編輯1:刪除獵戶座Docker鏡像的“開發”后,我現在正在運行獵戶座的“1.6.0-next”verison,我沒有任何運行時錯誤。 但是,我無法獲得實體屬性的任何歷史價值。 我必須在請求中做一些錯誤,但我不知道在哪里。

現在我的docker-compose文件如下所示:

mongo:
  image: mongo:3.2
  command: --nojournal

orion:
    image: fiware/orion
    links:
        - mongo
    ports:
        - "1026:1026"
    command: -dbhost mongo

fiware-sth-comet:
  image: telefonicaiot/fiware-sth-comet
  links:
    - mongo
  ports:
    - "8666:8666"
  environment:
    - STH_HOST=0.0.0.0
    - DB_URI=mongo:27017

cygnus:
  image: fiware/cygnus-ngsi
  links:
    -mongo

編輯2:關注 @GermánTorodelValle建議,我嘗試模擬對STH容器的通知,如CB將發送:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "Fiware-Service: myService" -H "Fiware-ServicePath: /myServicePath" -d '{
"subscriptionId" : "57a9ce8ae997e37e85a4be39",
"originator" : "orion.contextBroker.instance",
"contextResponses" : [
    {
        "contextElement" : {
            "attributes" : [
                {
                    "name" : "class",
                    "type" : "Text",
                    "value" : "monitor"
                }
            ],
            "type" : "cameraSimple",
            "isPattern" : "false",
            "id" : "sensor03"
        },
        "statusCode" : {
            "code" : "200",
            "reasonPhrase" : "OK"
        }
    }
]
}' "http://172.17.0.1:8666/notify"

登錄STH容器如下:

time=2017-02-02T13:50:36.809Z | lvl=ERROR | corr=39638217-c300-48c0-9122-bff6164d5298 | trans=39638217-c300-48c0-9122-bff6164d5298 | op=OPER_STH_POST | from=n/a | srv=myService | subsrv=/myServicePath | comp=STH | msg=Error when getting the raw data collection for storing:MongoError: db already exists with different case already have: [sth_myservice] trying to create [sth_myService]
time=2017-02-02T13:50:36.810Z | lvl=WARN | corr=c322ddc8-2140-484b-a123-4e5b9b60742e | trans=c322ddc8-2140-484b-a123-4e5b9b60742e | op=OPER_STH_POST | from=n/a | srv=myService | subsrv=/myServicePath | comp=STH | msg=POST /notify, event={"request":"1486043436805:3577e9b29ee6:1:iym1stlz:10018","timestamp":1486043436810,"tags":["handler","error"],"data":{"msec":3.6443320512771606,"error":"db already exists with different case already have: [sth_myservice] trying to create [sth_myService]","data":{"name":"MongoError","message":"db already exists with different case already have: [sth_myservice] trying to create [sth_myService]","ok":0,"errmsg":"db already exists with different case already have: [sth_myservice] trying to create [sth_myService]","code":13297,"isBoom":true,"isServer":true,"data":null,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{}}}},"internal":true}
time=2017-02-02T13:50:36.812Z | lvl=ERROR | corr=6c864793-c7ef-462a-a43d-75cdae8d20a3 | trans=6c864793-c7ef-462a-a43d-75cdae8d20a3 | op=OPER_STH_POST | from=n/a | srv=myService | subsrv=/myServicePath | comp=STH | msg=POST /notify, event={"request":"1486043436805:3577e9b29ee6:1:iym1stlz:10018","timestamp":1486043436811,"tags":["internal","error"],"data":{"name":"MongoError","message":"db already exists with different case already have: [sth_myservice] trying to create [sth_myService]","ok":0,"errmsg":"db already exists with different case already have: [sth_myservice] trying to create [sth_myService]","code":13297,"isBoom":true,"isServer":true,"data":null,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{"content-type":"application/json; charset=utf-8","cache-control":"no-cache","content-length":96}}},"internal":true}
time=2017-02-02T13:50:38.143Z | lvl=INFO | corr=n/a | trans=n/a | op=OPER_STH_SERVER_LOG | from=n/a | srv=n/a | subsrv=n/a | comp=STH | msg=Everything OK, 0 requests attended in the last 60s interval

由於問題是如此獨立和完整(非常感謝你,@ lukas),讓我簡單地說兩個方面作為總結和回答:

  1. STH僅支持NGSI v1通知,因此請使用NGSI v1將STH訂閱到Context Broker實例。
  2. MongoDB數據庫強制要求2個數據庫不能具有相同的名稱但不同的大小寫(請參閱https://docs.mongodb.com/manual/reference/limits/#naming-restrictions ),因此您不能使用2個不同的服務名稱由於數據庫名稱是從服務名稱生成的,因此只能使用STH更改其大小寫。 myservice ,您不能將myservicemyService用作STH將聚合數據的服務。 在其中任何一個上加入一些額外的角色,一切都應該沒問題。

非常感謝你! ;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM