首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fiware - Orion上下文代理订阅没有发送给STH,“条件应该是一个数组”

Fiware - Orion上下文代理订阅没有发送给STH,“条件应该是一个数组”
EN

Stack Overflow用户
提问于 2017-01-27 14:06:13
回答 1查看 860关注 0票数 5

当尝试使用STH来存储和检索发送给OCB的数据时,我在订阅时遇到了问题。

我的问题是订阅创建工作进展顺利。创建订阅时,如下所示:

代码语言:javascript
复制
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"
}

我收到以下答复:

代码语言:javascript
复制
{
  "subscribeResponse": {
    "subscriptionId": "588b4f38e2066a50fa98df9b",
    "duration": "P1M",
    "throttling": "PT5S"
  }
}

但是在Fiware服务器上,我看到一个关于运行容器的终端条件的错误,还有一个关于属性的错误:

代码语言:javascript
复制
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)

另外,在更新实体上的值时,

代码语言:javascript
复制
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时一无所获:

代码语言:javascript
复制
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

返回:

代码语言:javascript
复制
{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "class",
            "values": []
          }
        ],
        "id": "sensor03",
        "isPattern": false,
        "type": "myDevice"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

注意:

  • 我使用NGSI V1,因为我怀疑V2还不支持STH接收有关问题的NGSI V2通知。此外,我也没有找到任何与NGSI V2有关的“获取历史原始上下文信息”的文档,例如在此页上。
  • 我使用的是在Fiware-Lab上运行的带有单个Debian 8 VM的Docker-机器,其图像如下: mongodb:图像: mongo:2.6主机名: mongodb container_name: mongodb命令:- -dbhost mongodb命令:--dbhost mongodb fiware/ orion:-dbhost mongodb/ orion :develop主机名: orion container_name: orion链接:-mongodb公开:- "1026“端口:- "1026:1026”命令:-dbhost mongodb fiware-东西-comet链接:- mongodb端口:- "8666:8666“环境:- STH_HOST=0.0.0.0 - DB_URI=mongodb:27017

编辑1:删除猎户座码头图像的“开发”后,我现在运行的是Orion的verison "1.6.0-next“,而且我没有任何运行时错误。尽管如此,我仍然无法获得实体属性的任何历史值。我一定是在请求中出错了,但我不知道在哪里。

现在,我的停靠撰写文件如下所示:

代码语言:javascript
复制
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建议,我尝试像CB发送的那样模拟对STH容器的通知:

代码语言:javascript
复制
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容器上的登录如下:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-30 12:22:37

由于这个问题是如此全面和完整(非常感谢你的回答,@lukas),让我简单地回答以下两个方面:

  1. STH只支持NGSI v1通知,因此请使用v1订阅STH到上下文代理实例。
  2. MongoDB数据库限制了两个数据库不能具有相同的名称,而不能具有不同的大写(请参阅https://docs.mongodb.com/manual/reference/limits/#naming-restrictions),因此您不能使用两个不同的服务名称,因为数据库名称是从服务名称生成的,因此它们只能随服务名称而改变它们的大小写。也就是说,您不能使用myservicemyService作为服务,因为STH将为它们聚合数据。在他们中的任何一个上加入一些额外的字符,一切都应该是好的。

非常感谢!)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41895831

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档