Fiware 物联网代理 Json 拒绝 POST 到 /v2/op/update
Fiware IoT Agent Json refused to POST to /v2/op/update
我对 fiware IoT Agent 很感兴趣 JSON,并且我尝试解决了问题。
我已经使用 this 教程安装了物联网代理 JSON。
本教程涉及 IoT Actuator Connection 并检查我们必须 POST 到 {IoTAgentIP:Port}/v2/op/update 的连接。
当我 post 到达此端点时,我得到:
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /v2/op/update</pre>
</body>
</html>
我的 Post 命令是:
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update",
"entities": [
{
"type": "Alarm",
"id": "urn:ngsi-ld:Alarm:001",
"ring" : {
"type": "command",
"value": ""
}
}
]
}'
和
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update",
"entities": [
{
"type": "Bell",
"id": "urn:ngsi-ld:Bell:001",
"ring" : {
"type": "command",
"value": ""
}
}
]
}'
我的 IoT 代理版本是:
{
"libVersion": "2.12.0-next",
"port": 4041,
"baseRoot": "/",
"version": "1.14.0-next"
}
更新 - 使用最新版本的 IoTA 和 orion,我在 IoTA 日志文件中得到以下内容:
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Creating initial entity in the Context Broker:
{
"url": "http://localhost:1026/v1/updateContext",
"method": "POST",
"json": {
"contextElements": [
{
"type": "Bell",
"isPattern": "false",
"id": "urn:ngsi-ld:Bell:001",
"attributes": [
{
"name": "refStore",
"type": "Relationship",
"value": "urn:ngsi-ld:Store:001"
},
{
"name": "ring_status",
"type": "commandStatus",
"value": "UNKNOWN"
},
{
"name": "ring_info",
"type": "commandResult",
"value": " "
},
{
"name": "TimeInstant",
"type": "ISO8601",
"value": " "
}
]
}
],
"updateAction": "APPEND"
},
"headers": {
"fiware-service": "openiot",
"fiware-servicepath": "/",
"fiware-correlator": "7c9fba8d-9262-4f81-9b4e-f71ab57953ff"
}
} | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=executeWithSecurity | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Bell"} | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Bell"}] | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group for fields: [\"type\"] and values: {\"type\":\"Bell\"}","code":404} in get group device | comp=IoTAgent
time=2020-10-22T20:46:49.097Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Initial entity created successfully. | comp=IoTAgent
我设法让它与一个服务组 (/iot/d) 一起工作。因此 Post 附加传感器的请求来自 /iot/d 服务组。
我使用 docker 图像(使用 docker compose 编译,如示例)。
我还在 docker 文件中修改了 IOTA_DEFAULT_RESOURCE 以防万一:
IOTA_DEFAULT_RESOURCE=
我用过最新的 IoT Agent JSON 1.15.0 和之前的 Orion 2.4.0 版本。
我对 fiware IoT Agent 很感兴趣 JSON,并且我尝试解决了问题。 我已经使用 this 教程安装了物联网代理 JSON。 本教程涉及 IoT Actuator Connection 并检查我们必须 POST 到 {IoTAgentIP:Port}/v2/op/update 的连接。 当我 post 到达此端点时,我得到:
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /v2/op/update</pre>
</body>
</html>
我的 Post 命令是:
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update",
"entities": [
{
"type": "Alarm",
"id": "urn:ngsi-ld:Alarm:001",
"ring" : {
"type": "command",
"value": ""
}
}
]
}'
和
curl -iX POST \
http://localhost:4041/v2/op/update \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"actionType": "update",
"entities": [
{
"type": "Bell",
"id": "urn:ngsi-ld:Bell:001",
"ring" : {
"type": "command",
"value": ""
}
}
]
}'
我的 IoT 代理版本是:
{
"libVersion": "2.12.0-next",
"port": 4041,
"baseRoot": "/",
"version": "1.14.0-next"
}
更新 - 使用最新版本的 IoTA 和 orion,我在 IoTA 日志文件中得到以下内容:
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Creating initial entity in the Context Broker:
{
"url": "http://localhost:1026/v1/updateContext",
"method": "POST",
"json": {
"contextElements": [
{
"type": "Bell",
"isPattern": "false",
"id": "urn:ngsi-ld:Bell:001",
"attributes": [
{
"name": "refStore",
"type": "Relationship",
"value": "urn:ngsi-ld:Store:001"
},
{
"name": "ring_status",
"type": "commandStatus",
"value": "UNKNOWN"
},
{
"name": "ring_info",
"type": "commandResult",
"value": " "
},
{
"name": "TimeInstant",
"type": "ISO8601",
"value": " "
}
]
}
],
"updateAction": "APPEND"
},
"headers": {
"fiware-service": "openiot",
"fiware-servicepath": "/",
"fiware-correlator": "7c9fba8d-9262-4f81-9b4e-f71ab57953ff"
}
} | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=executeWithSecurity | comp=IoTAgent
time=2020-10-22T20:46:49.063Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Bell"} | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Bell"}] | comp=IoTAgent
time=2020-10-22T20:46:49.069Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group for fields: [\"type\"] and values: {\"type\":\"Bell\"}","code":404} in get group device | comp=IoTAgent
time=2020-10-22T20:46:49.097Z | lvl=DEBUG | corr=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | trans=7c9fba8d-9262-4f81-9b4e-f71ab57953ff | op=IoTAgentNGSI.DeviceService | srv=n/a | subsrv=n/a | msg=Initial entity created successfully. | comp=IoTAgent
我设法让它与一个服务组 (/iot/d) 一起工作。因此 Post 附加传感器的请求来自 /iot/d 服务组。
我使用 docker 图像(使用 docker compose 编译,如示例)。
我还在 docker 文件中修改了 IOTA_DEFAULT_RESOURCE 以防万一:
IOTA_DEFAULT_RESOURCE=
我用过最新的 IoT Agent JSON 1.15.0 和之前的 Orion 2.4.0 版本。