gpt4 book ai didi

fiware - 使用 dockerized fiware-orion 似乎无法进行订阅

转载 作者:行者123 更新时间:2023-12-01 17:30:28 29 4
gpt4 key购买 nike

我正在使用 Fiware-Orion ContextBroker 0.28,这是 ubuntu 15.10 64 位上的本地主机中的 Docker 化版本。

$ curl localhost:1026/version
{
"orion" : {
"version" : "0.28.0-next",
"uptime" : "0 d, 0 h, 0 m, 6 s",
"git_hash" : "067e13618c247daa4af61f82d7831f3015d9eb5d",
"compile_time" : "Mon Mar 14 13:04:02 UTC 2016",
"compiled_by" : "root",
"compiled_in" : "838a42ae8431"
}
}

我使用的docker配置是:

$ cat docker-compose.yml 
mongo:
image: mongo:2.6
command: --smallfiles --nojournal
orion:
image: fiware/orion
links:
- mongo
ports:
- "1026:1026"
command: -dbhost mongo

当我订阅时,我从 orion/docker 收到的警告是:

orion_1 | WARNING@12:19:14  AlarmManager.cpp[303]: Raising alarm NotificationError localhost:1028/accumulate: (curl_easy_perform failed: Couldn't connect to server)

我正在关注 API V1 walkthorugh测试对更改的订阅。我从一个全新的 dockerized(sudo docker-compose up 和所有这些模糊)fiware-orion 0.28 和 mongodb 开始。然后我启动累加器

$ ./accumulator-server.py 1028 /accumulate localhost on
verbose mode is on
* Running on http://localhost:1028/ (Press CTRL+C to quit)

然后我注册 Room1

$ (curl localhost:1026/v1/updateContext -s -S --header 'Content-Type: application/json' \
> --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
> {
> "contextElements": [
> {
> "type": "Room",
> "isPattern": "false",
> "id": "Room1",
> "attributes": [
> {
> "name": "temperature",
> "type": "float",
> "value": "23"
> },
> {
> "name": "pressure",
> "type": "integer",
> "value": "720"
> }
> ]
> }
> ],
> "updateAction": "APPEND"
> }
> EOF
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": ""
},
{
"name": "pressure",
"type": "integer",
"value": ""
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}

然后我测试查询上下文只是为了检查:

$ (curl localhost:1026/v1/queryContext -s -S --header 'Content-Type: application/json' \
> --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
> {
> "entities": [
> {
> "type": "Room",
> "isPattern": "false",
> "id": "Room1"
> }
> ]
> }
> EOF
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "pressure",
"type": "integer",
"value": "720"
},
{
"name": "temperature",
"type": "float",
"value": "23"
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}

然后我订阅

$ (curl localhost:1026/v1/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": [
> "pressure"
> ],
> "reference": "http://localhost:1028/accumulate",
> "duration": "P1M",
> "notifyConditions": [
> {
> "type": "ONCHANGE",
> "condValues": [
> "pressure"
> ]
> }
> ],
> "throttling": "PT5S"
> }
> EOF
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "570f8ac247fcf8a62722353c",
"throttling": "PT5S"
}
}

此时,手册说累加器可能会收到第一次更新,但这不是必需的,所以我什么也没有收到,但也许没关系。或者也许不是,因为发送订阅查询后,orion 的 docker 会说:

orion_1 | WARNING@12:19:14  AlarmManager.cpp[303]: Raising alarm NotificationError localhost:1028/accumulate: (curl_easy_perform failed: Couldn't connect to server)

最后我更新了实体,我应该收到累加器的更新,但我没有:

$ (curl localhost:1026/v1/updateContext -s -S --header 'Content-Type: application/json' \
> --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
> {
> "contextElements": [
> {
> "type": "Room",
> "isPattern": "false",
> "id": "Room1",
> "attributes": [
> {
> "name": "temperature",
> "type": "float",
> "value": "56.5"
> },
> {
> "name": "pressure",
> "type": "integer",
> "value": "553"
> }
> ]
> }
> ],
> "updateAction": "UPDATE"
> }
> EOF
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": ""
},
{
"name": "pressure",
"type": "integer",
"value": ""
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}

我还应该说,在 Ubuntu 上编译 fiware-orion 相当困难,这就是我使用 docker 的原因。

最佳答案

看起来答案就在 ifconfig 上。

$ ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:09:7b:6e:b7
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:9ff:fe7b:6eb7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1036 errors:0 dropped:0 overruns:0 frame:0
TX packets:1506 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

这意味着对于 docker orion 机器,主机位于 172.17.0.1。

累加器应以以下方式启动:

$  ./accumulator-server.py 1028 /accumulate 172.17.0.1 on

订阅命令应该类似于(使用“reference”:“http://172.17.0.1:1028/accumulate”):

(curl localhost:1026/v1/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",
"pressure"
],
"reference": "http://172.17.0.1:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"temperature",
"pressure"
]
}
],
"throttling": "PT1S"
}
EOF

至少这个解决方案对我有用

关于fiware - 使用 dockerized fiware-orion 似乎无法进行订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36624433/

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