【发布时间】:2018-10-20 17:04:39
【问题描述】:
我已经使用 docker 部署了物联网堆栈。这些是使用过的容器:
- fiware/orion:1.13.0
- fiware/iotagent-json:1.8.0
- eclipse-mosquitto:1.4.12
- [问题未涉及的其他容器...]
我在代理上注册了以下设备:
{
"device_id": "t3",
"service": "lmobile",
"service_path": "/lmobile_Industry",
"entity_name": "t3",
"entity_type": "Device",
"endpoint": "tcp://<mqttborker_publicip>:<port>",
"transport": "MQTT",
"attributes": [{
"object_id": "led",
"name": "led",
"type": "text"
}],
"lazy": [],
"commands": [{
"object_id": "c",
"name": "c",
"type": "Command"
}],
"static_attributes": [
....
],
"protocol": "JSON"
}
并且已在 OCB 上正确创建了相应的实体,当我在 mqttbroker 上发布新度量时,在主题 /<apikey>/t3/attrs 下,该度量已正确转发到 OCB。
为了向设备发送命令 c,我在 OCB 上发送以下 updateContext:
curl -s -X POST http://<orionhost>:1026/v1/updateContext
-H 'accept: application/json'
-H 'cache-control: no-cache'
-H 'content-type: application/json'
-H 'fiware-service: lmobile'
-H 'fiware-servicepath: /lmobile_Industry'
-d '{
"contextElements": [
{
"type": "Device",
"isPattern": "false",
"id": "t3",
"attributes": [
{
"name":"c",
"type":"Command",
"value":100
}
]
}
],
"updateAction": "UPDATE"
}'
我收到以下错误响应:
{
"errorCode": {
"code": "404",
"reasonPhrase": "No context element found",
"details": "invalid context provider response"
}
}
在 OCB 日志中,我可以看到以下警告消息:
time=Thursday 18 Oct 08:55:54 2018.431Z | lvl=WARN | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=postQueryContext.cpp[169]:queryForward | msg=Other Error (context provider response to QueryContext is empty)。
无论如何,updateContext 已正确转发给 Agent。
在代理日志中(在 DEBUG 中)我可以看到以下内容:
iotstack_agent-json.1.xyz@xerus-1 | time=2018-10-18T09:02:33.975Z | lvl=DEBUG | corr=8d2864ec-d2b4-11e8-b445-02420aff0161 | trans=de5680e7-0727-4577-ac44-ddeb59df1f31 | op=IoTAgentNGSI.GenericMiddlewares | srv=lmobile | subsrv=/lmobile_Industry | msg=Request for path [/updateContext] from [<agent_publicip>:<port>] | comp=IoTAgent
iotstack_agent-json.1.xyz@xerus-1 | time=2018-10-18T09:02:33.976Z | lvl=DEBUG | corr=8d2864ec-d2b4-11e8-b445-02420aff0161 | trans=de5680e7-0727-4577-ac44-ddeb59df1f31 | op=IoTAgentNGSI.GenericMiddlewares | srv=lmobile | subsrv=/lmobile_Industry | msg=Body:
iotstack_agent-json.1.xyz@xerus-1 |
iotstack_agent-json.1.xyz@xerus-1 | {
iotstack_agent-json.1.xyz@xerus-1 | "contextElements": [
iotstack_agent-json.1.xyz@xerus-1 | {
iotstack_agent-json.1.xyz@xerus-1 | "type": "Device",
iotstack_agent-json.1.xyz@xerus-1 | "isPattern": "false",
iotstack_agent-json.1.xyz@xerus-1 | "id": "t3",
iotstack_agent-json.1.xyz@xerus-1 | "attributes": [
iotstack_agent-json.1.xyz@xerus-1 | {
iotstack_agent-json.1.xyz@xerus-1 | "name": "c",
iotstack_agent-json.1.xyz@xerus-1 | "type": "Command",
iotstack_agent-json.1.xyz@xerus-1 | "value": "100"
iotstack_agent-json.1.xyz@xerus-1 | }
iotstack_agent-json.1.xyz@xerus-1 | ]
iotstack_agent-json.1.xyz@xerus-1 | }
iotstack_agent-json.1.xyz@xerus-1 | ],
iotstack_agent-json.1.xyz@xerus-1 | "updateAction": "UPDATE"
iotstack_agent-json.1.xyz@xerus-1 | }
iotstack_agent-json.1.xyz@xerus-1 |
iotstack_agent-json.1.xyz@xerus-1 | | comp=IoTAgent
iotstack_agent-json.1.xyz@xerus-1 | time=2018-10-18T09:02:33.978Z | lvl=DEBUG | corr=8d2864ec-d2b4-11e8-b445-02420aff0161 | trans=de5680e7-0727-4577-ac44-ddeb59df1f31 | op=IoTAgentNGSI.DomainControl | srv=lmobile | subsrv=/lmobile_Industry | msg=response-time: 6 | comp=IoTAgent
在这里我没有看到警告或错误,但没有任何命令被转发到任何主题的 MQTT 代理(我订阅了命令/<apikey>/t3/cmd 的特定主题和使用通配符# 订阅的所有主题)。
【问题讨论】:
标签: mqtt iot fiware fiware-orion