Fiware IotAgent:can';t向设备发送命令

Fiware IotAgent:can';t向设备发送命令,fiware,fiware-orion,Fiware,Fiware Orion,我在物联网代理中批准了我的设备,如下所示: curl -X POST http://192.168.1.110:80/iot/devices \ -i \ -H "Content-Type: application/json" \ -H "Fiware-Service: egmsmartcity" \ -H "Fiware-ServicePath: /egmsmartcitypath" \ -d ' { "devices": [ { "device_id": "test", "entity_n

我在物联网代理中批准了我的设备,如下所示:

curl -X POST http://192.168.1.110:80/iot/devices \
-i \
-H "Content-Type: application/json" \
-H "Fiware-Service: egmsmartcity" \
-H "Fiware-ServicePath: /egmsmartcitypath" \
-d ' { "devices": [ { "device_id": "test",
 "entity_name": "sensors:test",
 "entity_type": "sensors",
"protocol": "PDI-IoTA-MQTT-UltraLight",
 "timezone": "Europe/Paris",
 "endpoint": "notUsed",
 "commands": [{ "name": "ping", "type": "command", "value": ""}]  } ] }'
它在上下文代理中成功注册:

上车:

带标题:

Accept: application/json
Fiware-Service: egmsmartcity
Fiware-ServicePath: /egmsmartcitypath
我得到的答复如下:

{
contextElement: {
type: "sensors"
isPattern: "false"
id: "sensors:test"
attributes: [1]
0:  {
name: "TimeInstant"
type: "ISO8601"
value: "2015-11-30T16:53:45.556269Z"
}-
-
}-
statusCode: {
code: "200"
reasonPhrase: "OK"
}-
}
HTTP/1.1 200 OK
Content-Length: 157
Content-Type: application/xml
Date: Mon, 30 Nov 2015 17:05:11 GMT

<updateContextResponse>
  <errorCode>
    <code>404</code>
    <reasonPhrase>No context element found</reasonPhrase>
  </errorCode>
</updateContextResponse>
然后当我尝试像这样更新命令时:

curl -X POST http://192.168.1.77:1026/v1/updateContext \
     -i \
-H "Content-Type: application/json" \
-H "Fiware-Service: egmsmartcity" \
-H "Fiware-ServicePath: /egmsmartcitypath" \
-d ' {"updateAction":"UPDATE","contextElements":[{"id":"sensors:test","type":"sensors","isPattern":"false","attributes":[{"name":"ping","type":"command","value":"22" } ]} ]}'
我得到的回答是:

{
contextElement: {
type: "sensors"
isPattern: "false"
id: "sensors:test"
attributes: [1]
0:  {
name: "TimeInstant"
type: "ISO8601"
value: "2015-11-30T16:53:45.556269Z"
}-
-
}-
statusCode: {
code: "200"
reasonPhrase: "OK"
}-
}
HTTP/1.1 200 OK
Content-Length: 157
Content-Type: application/xml
Date: Mon, 30 Nov 2015 17:05:11 GMT

<updateContextResponse>
  <errorCode>
    <code>404</code>
    <reasonPhrase>No context element found</reasonPhrase>
  </errorCode>
</updateContextResponse>
为什么返回“未找到上下文元素”?我错过了什么? 提前感谢您的帮助

[更新] 我尝试了一个简单的“物联网/设备” 以下是Iot代理lg文件中的日志:

如果操作成功,请从本地主机

HTTP Version:  1.1
Resource requested: /iot/devices
Resource delivered: /iot/devices
Query string 
Content length: 0
Headers: Fiware-ServicePath: /egmsmartcitypath
Fiware-Service: egmsmartcity
User-Agent: curl/7.29.0
Host: localhost
Content-Type: application/json
Accept: */*

time=2015-12-02T10:41:41,516.800CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=operator() | file=[140373934458624:rest_handle.cc:396] | msg=Processing request /iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 
time=2015-12-02T10:41:41,516.813CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=execute_filters | file=[140373934458624:rest_handle.cc:410] | msg=Processing request /iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 
time=2015-12-02T10:41:41,516.820CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=execute_filters | file=[140373934458624:rest_handle.cc:411] | msg=execute_filters status:  200 
time=2015-12-02T10:41:41,516.953CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140374294497024:media_filter.cc:56] | msg=MediaFilter handle_request /iot-754c76a3-b95a-4aac-976a-08ab37119c05-34/iot/devices 
time=2015-12-02T10:41:41,516.982CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140374294497024:media_filter.cc:95] | msg=Accept: */* 
time=2015-12-02T10:41:41,517.035CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_end_filters | file=[140373934458624:rest_handle.cc:446] | msg=Processing request /iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 
time=2015-12-02T10:41:41,517.046CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_end_filters | file=[140373934458624:rest_handle.cc:447] | msg=End filters status 200 
time=2015-12-02T10:41:41,517.056CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140373934458624:rest_handle.cc:492] | msg=Processing request /iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 
time=2015-12-02T10:41:41,517.062CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140373934458624:rest_handle.cc:493] | msg=Proccessing in handle /iot 
time=2015-12-02T10:41:41,517.180CET | lvl= INFO | comp=iota:IoTAgent-MQTT-UL20 | op=devices | file=[140373934458624:admin_service.cc:586] | msg=iota::AdminService::devices method:GET trace_message:/iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 
time=2015-12-02T10:41:41,517.215CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=get_all_devices_json | file=[140373934458624:admin_service.cc:1748] | msg=get_all_devices_json service=egmsmartcity service_path=/egmsmartcitypath detailed= 
time=2015-12-02T10:41:41,517.234CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=conn | file=[140373934458624:mongo_connection.cc:261] | msg=MongoConnection::conn returns 0x20ba8f0 
time=2015-12-02T10:41:41,517.262CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=count | file=[140373934458624:collection.cc:833] | msg=Collection:count bbdd=iot.DEVICE options= query={ service: "egmsmartcity", service_path: "/egmsmartcitypath" } 
time=2015-12-02T10:41:41,517.524CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=find | file=[140373934458624:collection.cc:704] | msg=Collection:find bbdd=iot.DEVICE query={ service: "egmsmartcity", service_path: "/egmsmartcitypath" } limit=20 offset=0 options=-2147483648 
time=2015-12-02T10:41:41,517.546CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=find | file=[140373934458624:collection.cc:718] | msg=before getConnection 
time=2015-12-02T10:41:41,517.553CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=find | file=[140373934458624:collection.cc:723] | msg=before query 
time=2015-12-02T10:41:41,517.737CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=create_response | file=[140373934458624:admin_service.cc:1309] | msg=create_response: 200 { "count": 2,"devices": [{ "device_id" : "sensorTmp" },{ "device_id" : "test" }]} 
time=2015-12-02T10:41:41,517.766CET | lvl= INFO | comp=iota:IoTAgent-MQTT-UL20 | op=devices | file=[140373934458624:admin_service.cc:718] | msg=iota::AdminService::devices method:GET trace_message:/iot-754c76a3-b95a-4aac-976a-08ab37119c05-34 code: 200 response:{ "count": 2,"devices": [{ "device_id" : "sensorTmp" },{ "device_id" : "test" }]} 
time=2015-12-02T10:41:41,517.902CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=finish | file=[140373934458624:rest_handle.cc:567] | msg=finish connection 2
如果操作未成功,请从Rest客户端

HTTP Version:  1.1
Resource requested: /iot/devices/
Resource delivered: /iot/devices/
Query string 
Content length: 0
Headers: Fiware-ServicePath: /egmsmartcitypath
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
Fiware-Service: egmsmartcity
Connection: keep-alive
Host: 192.168.1.110
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Encoding: gzip, deflate, sdch
Accept: */*
Content-Type: application/json

time=2015-12-02T10:39:55,246.079CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=operator() | file=[140373942851328:rest_handle.cc:396] | msg=Processing request /iot-c7a1ab03-73e6-4f9b-82de-d8f569927296-33 
time=2015-12-02T10:39:55,246.079CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=execute_filters | file=[140373942851328:rest_handle.cc:410] | msg=Processing request /iot-c7a1ab03-73e6-4f9b-82de-d8f569927296-33 
time=2015-12-02T10:39:55,246.079CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=execute_filters | file=[140373942851328:rest_handle.cc:411] | msg=execute_filters status:  200 
time=2015-12-02T10:39:55,246.156CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140374294497024:media_filter.cc:56] | msg=MediaFilter handle_request /iot-c7a1ab03-73e6-4f9b-82de-d8f569927296-33/iot/devices/ 
time=2015-12-02T10:39:55,246.191CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140374294497024:media_filter.cc:95] | msg=Accept: */* 
time=2015-12-02T10:39:55,246.338CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_end_filters | file=[140373942851328:rest_handle.cc:446] | msg=Processing request /iot-c7a1ab03-73e6-4f9b-82de-d8f569927296-33 
time=2015-12-02T10:39:55,246.350CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_end_filters | file=[140373942851328:rest_handle.cc:447] | msg=End filters status 200 
time=2015-12-02T10:39:55,246.360CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140373942851328:rest_handle.cc:492] | msg=Processing request /iot-c7a1ab03-73e6-4f9b-82de-d8f569927296-33 
time=2015-12-02T10:39:55,246.366CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=handle_request | file=[140373942851328:rest_handle.cc:493] | msg=Proccessing in handle /iot 
time=2015-12-02T10:39:55,246.586CET | lvl=DEBUG | comp=iota:IoTAgent-MQTT-UL20 | op=finish | file=[140373942851328:rest_handle.cc:567] | msg=finish connection 2

iot代理似乎在终止请求处理之前完成了操作

iot代理似乎无法响应updateContext请求。当您将属性声明为命令时,IoT代理将自己注册为上下文代理中设备实体的该属性的上下文提供程序。如果CB收到该属性的更新请求,则该请求将转发至IoTA。如果IoTA无法应答或未找到,请求将失败


这个问题的可能原因是对公共知识产权的错误配置。如果上下文代理找不到要更新的属性的提供者,它将返回404错误。您是否在IoT代理中配置了公共IP

IoT代理和上下文代理位于同一个本地网络中,我可以从上下文代理ping IoT代理,我还检查了IoT代理中的防火墙,它被禁用(iptables.service和firewalld.service)