2016-04-14 7 views
2

私のローカルホストでubuntu 15.10 64ビットのドッキングバージョンである、Fiware-Orion ContextBroker 0.28を使用しています。サブスクリプションがドッキングされたfi-orionを使用して動作していないようです

$ 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" 
} 
} 

私が使用しているドッキングウィンドウ構成は次のとおりです。

$ 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_1 | [email protected]: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とすべてのfuzz)のfiware-orion 0.28から始めます。

$ (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" 
    } 
} 
の操作を行います。それから私は、アキュムレータ

$ ./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" 
      } 
     } 
    ] 
} 

を登録その後、私はちょうどチェックするために、クエリコンテキストをテスト開始します

この時点で、男性アキュムレータは最初のアップデートを受け取るかもしれないが、それは必須ではないので、私は何も受け取っていませんが、おそらくそれは問題ありません。またはそうでないかもしれない、サブスクリプションのクエリを送信した後、オリオンのドッキングウィンドウが言うので:

orion_1 | [email protected]: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でコンパイルするためにfi-orionをコンパイルすることは非常に難しいと言います。それが私がドッカーを使用している理由です。

+0

コンパイルOrionはCentOSでのみサポートされていますが、わずかな変更でUbuntuで実行するのはあまり難しくありません。 – LeandroGuillen

答えて

2

ターゲットサブスクリプションのURL(「参照」属性)を変更する必要があります。 Docker内でOrionを実行している場合、OrionへのローカルホストはDocker自体であり、マシンではありません。そのため、通知はDockerのlocalhostポート1028に送信されています。Dockerポート1028でリッスンしているアプリケーションが存在しない可能性があるため、カールエラーが発生します。

蓄積サーバを別のマシンに設定するか、(ngrokなどを使用して)マシンのローカルホストにトンネルを作成し、そのアドレスへのサブスクリプションリファレンスを設定してください。

3

答えは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 

加入するコマンド( "参照" を使用して: "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 

は、少なくともこのソリューションは、私の作品

関連する問題