订阅后未收到Orion Context-broker的通知

时间:2014-04-29 13:07:46

标签: fiware-orion

我正在尝试“用户和程序员指南”中的示例,但我在订阅后未收到任何通知。更新和查询运行良好。 “受体”脚本以这种方式启动

./accumulator-server.py 1028 /accumulate on

似乎&运行过程中出现

verbose mode is on
 * Running on http://0.0.0.0:1028/ 

然后订阅似乎也可以

(curl localhost:1026/NGSI10/subscribeContext -s -S --header 'Content-Type: application/json' --      header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
    "entities": [
        {
        "type": "Room",
        "isPattern": "false",
        "id": "Room1"
    }
],
"attributes": [
    "temperature"
],
"reference": "http://localhost:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
        {
            "type": "ONTIMEINTERVAL",
            "condValues": [
                "PT10S"
            ]
        }
    ]
    }
   EOF

响应:

{
    "subscribeResponse": {
    "duration": "P1M", 
    "subscriptionId": "535e558d28604367380deb5c"
    }
}

然后,更新Room1

curl  -v localhost:1026/NGSI10/updateContext --header 'Content-Type: application/json' --header 'Accept: application/json' -d @-  <<EOF
> {
>     "contextElements": [
>         {
>             "type": "Room",
>             "isPattern": "false",
>             "id": "Room1",
>             "attributes": [
>             {
>                 "name": "temperature",
>                 "type": "centigrade",
>                 "value": "x"
>             },
>             {
>                 "name": "pressure",
>                 "type": "mmHg",
>                 "value": "x"
>             }
>             ]
>         }
>     ],
>     "updateAction": "UPDATE"
> }
> EOF
* About to connect() to localhost port 1026 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 1026 (#0)
> POST /NGSI10/updateContext HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host: localhost:1026
> Content-Type: application/json
> Accept: application/json
> Content-Length: 454
> 
< HTTP/1.1 200 OK
< Content-Length: 513
< Content-Type: application/json
< Date: Mon, 28 Apr 2014 12:08:38 GMT
< 
{
  "contextResponses" : [
    {
      "contextElement" : {
        "type" : "Room",
        "isPattern" : "false",
        "id" : "Room1",
        "attributes" : [
          {
            "name" : "temperature",
            "type" : "centigrade",
            "value" : ""
          },
          {
            "name" : "pressure",
            "type" : "mmHg",
            "value" : ""
          }
        ]
      },
      "statusCode" : {
        "code" : "200",
        "reasonPhrase" : "OK"
      }
    }
  ]
}
* Connection #0 to host localhost left intact
* Closing connection #0

accumulator-server的输出

没有显示任何内容

关于我可能做错什么的任何想法?

1 个答案:

答案 0 :(得分:0)

这实际上是由于&#34;文档错误&#34;在用户手册中。

自版本0.10.0起,Orion Context Broker能够在IPv4和IPv6以及&#34; localhost&#34;中发送通知。在subscribeContext操作中的reference元素中使用的往往由操作系统解析为IPv6。因此,默认情况下会在IPv6中发送通知,但如果使用

运行累加器服务器
./accumulator-server.py 1028 /accumulate on

然后它只收听IPv4。

accumulator-server.py允许在命令行中指定列表地址,因此如果使用以下命令指定:: 1(IPv6的localhost)

./accumulator-server.py 1028 /accumulate ::1 on

那么它应该可以正常工作。这由以下输出确认:

verbose mode is on
* Running on http://[::1]:1028/
* Restarting with reloader
verbose mode is on

(注意&#34中的:: 1;上面的&#34;上面的行,不同于仅限IPv4的情况的0.0.0.0)

感谢您的反馈,用户手册已修复,现在它使用了正确的命令:)