我正在“用户和程序员指南”中尝试示例,但订阅后我没有收到任何通知。更新和查询运行良好。“receptor”脚本就是这样启动的
./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
's 的输出中没有显示任何内容
知道我做错了什么吗?