使用dockerized fiware-orion订阅似乎无法正常工作 [英] Subscriptions don't seem to work using dockerized fiware-orion
问题描述
我正在使用Fiware-Orion ContextBroker 0.28,这是我的本地主机上ubuntu 15.10 64位的dockerized版本.
I'm using Fiware-Orion ContextBroker 0.28, the dockerized version in my localhost on ubuntu 15.10 64 bits.
$ 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配置是:
The docker configuration I'm using is:
$ 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得到的警告是:
The warning I get from orion/docker when I do the subscriptions is:
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 来测试对更改的订阅.我首先使用mongodb创建一个全新的dockerized(sudo docker-compose up和所有类似的东西)fiware-orion 0.28.然后我启动蓄电池
I'm following the API V1 walkthorugh to test subscriptions to changes. I start with a mint new dockerized (sudo docker-compose up and all that fuzz) fiware-orion 0.28 with mongodb. Then I start the accumulator
$ ./accumulator-server.py 1028 /accumulate localhost on
verbose mode is on
* Running on http://localhost:1028/ (Press CTRL+C to quit)
然后我注册Room1
Then I register 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"
}
}
]
}
然后我测试查询上下文只是为了检查:
Then I test query context just to check:
$ (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"
}
}
在这一点上,手册说累加器可能会收到第一次更新,但这不是必需的,因此我什么也没收到,但也许还可以.也许不是,因为在发送订阅查询后,猎户座的码头工人说:
At this point the manual says that the accumulator might receive a first update but it's not required, so I don't receive nothing but maybe that's OK. Or maybe not, because after sending the subscription query, orion's docker says:
orion_1 | WARNING@12:19:14 AlarmManager.cpp[303]: Raising alarm NotificationError localhost:1028/accumulate: (curl_easy_perform failed: Couldn't connect to server)
最后,我更新了实体,我应该在累加器上收到更新,但是我不这样做:
Finally I update the entity and I should receive the update on the accumulator, but I don't:
$ (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"
}
}
]
}
我还应该说,很难让fiware-orion在Ubuntu上进行编译,这就是我使用docker的原因.
I should also say that it's quite difficult to get fiware-orion to compile on Ubuntu, and that's the reason why I'm using docker.
推荐答案
答案似乎在ifconfig上.
It looks like the answer is on 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上.
This means that for the docker orion machine, the host is on 172.17.0.1.
累加器应以以下内容启动:
The accumulator should be started with:
$ ./accumulator-server.py 1028 /accumulate 172.17.0.1 on
订阅命令应类似于(使用引用":" http://172.17.0.1:1028/积累):
The subscribing command should be something like (using "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
至少此解决方案对我有用
At least this solution works for me
这篇关于使用dockerized fiware-orion订阅似乎无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!