gpt4 book ai didi

Fiware - Orion Context Broker 订阅未发送到 STH, "conditions was supposed to be an array"

转载 作者:行者123 更新时间:2023-12-04 21:34:35 24 4
gpt4 key购买 nike

当尝试使用 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,因为我怀疑 V2 尚不支持 STH 接收有关此的 NGSI V2 通知 issue .
    此外,我没有找到任何关于 NGSI V2 的“获取历史原始上下文信息”的文档,例如在 this page
  • 我将 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:删除 Orion Docker 镜像的“开发”后,我现在正在运行 Orion 的版本“1.6.0-next”,并且不再出现运行时错误。尽管如此,我还是无法获得实体属性的任何历史值(value)。我一定在请求中犯了一些错误,但我不知道在哪里。

    现在我的 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),让我只评论两个方面作为总结和答案:

  • STH 仅支持 NGSI v1 通知,因此请使用 NGSI v1 将 STH 订阅到上下文代理实例。
  • MongoDB 数据库强加了一项限制,即 2 个数据库不能具有相同的名称但大小写不同(请参阅 https://docs.mongodb.com/manual/reference/limits/#naming-restrictions),因此您不能使用 2 个不同的服务名称,这些服务名称仅随 STH 的大小写而变化,因为数据库名称是从服务生成的姓名。这是,您不能使用 myservicemyService作为 STH 将为其聚合数据的服务。在其中任何一个上添加一些额外的字符,一切都应该没问题。

  • 非常感谢! ;)

    关于Fiware - Orion Context Broker 订阅未发送到 STH, "conditions was supposed to be an array",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41895831/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com