Ошибка при обновлении сущностей с помощью Perseo в FIWARE
Я использую Perseo, пытаясь определить правило, которое обновляет атрибут объекта, используя этот почтовый запрос к Perseo:
curl -iX POST \
"http://localhost:9090/rules" \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"name": "temperature_rule2",
"text": "select *,\"temperature_rule2\" as ruleName, temperature? as temperature from iotEvent where cast(cast(temperature?, String), double)>22",
"action": {
"type": "update",
"parameters": {
"attributes": [
{
"name":"event",
"type":"Text",
"value":"event test"
}
]
}
}
}'
Но когда я меняю температуру, используя этот POST-запрос к агенту IoT:
curl -iX POST \
'http://localhost:7896/iot/json?i=temp001&k=1068318794' \
-H 'Content-Type: application/json' \
-d '{"t": "25"}'
the rule got fired based on the logs in Perseo container :
time=2022-06-19T08:49:08.612Z | lvl=DEBUG | corr=n/a | trans=n/a | op=n/a | msg=inserting in queue action {"type":"update","parameters":{"version":2,"attributes":[{"name":"event","type":"Text","value":"event test"}]},"index":0}
time=2022-06-19T08:49:08.612Z | lvl=DEBUG | corr=ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4 | trans=0c53aaae-fb87-427d-9f38-6b113cc8773b | op=/actions/do | path=/actions/do | comp=perseo-fe | srv=openiot | subsrv=/ | msg=executing axn task {"action":{"type":"update","parameters":{"version":2,"attributes":[{"name":"event","type":"Text","value":"event test"}]},"index":0},"event":{"service":"openiot","temperature":"10","ruleName":"temperature_rule1","id":"urn:ngsi-ld:Temp:001","type":"Temp","subservice":"/","fiwarePerseoContext":{"path":"/actions/do","op":"/actions/do","comp":"perseo-fe","trans":"0c53aaae-fb87-427d-9f38-6b113cc8773b","corr":"ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4","srv":"openiot","subsrv":"/"}},"context":{"path":"/actions/do","op":"/actions/do","comp":"perseo-fe","trans":"0c53aaae-fb87-427d-9f38-6b113cc8773b","corr":"ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4","srv":"openiot","subsrv":"/"}}
time=2022-06-19T08:49:08.622Z | lvl=DEBUG | corr=ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4 | trans=0c53aaae-fb87-427d-9f38-6b113cc8773b | op=/actions/do | path=/actions/do | comp=perseo-fe | srv=openiot | subsrv=/ | msg=action: {"type":"update","parameters":{"version":2,"attributes":[{"name":"event","type":"Text","value":"event test"}]},"index":0,"interval":0}, event: {"service":"openiot","temperature":"10","ruleName":"temperature_rule1","id":"urn:ngsi-ld:Temp:001","type":"Temp","subservice":"/","fiwarePerseoContext":{"path":"/actions/do","op":"/actions/do","comp":"perseo-fe","trans":"0c53aaae-fb87-427d-9f38-6b113cc8773b","corr":"ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4","srv":"openiot","subsrv":"/"}}
time=2022-06-19T08:49:08.623Z | lvl=DEBUG | corr=ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG; perseocep=4 | trans=0c53aaae-fb87-427d-9f38-6b113cc8773b | op=/actions/do | path=/actions/do | comp=perseo-fe | srv=openiot | subsrv=/ | msg=entity to update: {"actionType":"append","entities":[{"event":{"value":"event test","type":"Text"},"id":"urn:ngsi-ld:Temp:001","type":"Temp"}]}*
но объект не будет обновляться, и в журналах отображается эта ошибка:
time=2022-06-19T08:49:08.632Z | lvl=WARN | corr=ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG1655628444-237-00000000046 | trans=1655628444-237-00000000046 | from=172.18.0.10 | srv=openiot | subsrv=/ | comp=Orion | op=AlarmManager.cpp[496]:badInput | msg=Raising alarm BadInput 172.18.0.10: service '/v1/updateContext/v2/op/update' not found
time=2022-06-19T08:49:08.633Z | lvl=INFO | corr=ae8c8884-efac-11ec-9e52-0242ac12000c; cbnotif=1; node=G1RqnXD-NG1655628444-237-00000000046 | trans=1655628444-237-00000000046 | from=172.18.0.10 | srv=openiot | subsrv=/ | comp=Orion | op=logTracing.cpp[148]:logInfoRequestWithPayload | msg=Request received: POST /v1/updateContext/v2/op/update, request payload (125 bytes): {"actionType":"append","entities":[{"event":{"value":"event test","type":"Text"},"id":"urn:ngsi-ld:Temp:001","type":"Temp"}]}, response code: 400
почему здесь ошибка 400?
PS:
вот сущность, определенная для температуры:
{
"device_id": "temp001",
"entity_name": "urn:ngsi-ld:Temp:001",
"entity_type": "Temp",
"timezone": "Europe/Berlin",
"attributes": [
{ "object_id": "t", "name":"temperature", "type":"Integer"},
{ "object_id": "e", "name":"event", "type":"Text"}
],
"static_attributes": [
{"name": "refroom", "type": "Relationship","value": "urn:ngsi-ld:Room:001"}
]
}
Отредактировано:
Вот конфигурация для фронта и ядра orion и perseo:
services:
orion:
image: fiware/orion
hostname: orion
container_name: fiware-orion
depends_on:
- mongodb
expose:
- "1026"
ports:
- "1026:1026"
command: -logLevel DEBUG -noCache -dbhost mongodb -corsOrigin __ALL
healthcheck:
test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1
interval: 5s
iot-agent:
image: fiware/iotagent-json
hostname: iot-agent
container_name: fiware-iot-agent
depends_on:
- mongodb
expose:
- "4041"
- "7896"
ports:
- "4041:4041"
- "7896:7896"
environment:
- "IOTA_CB_HOST=orion"
- "IOTA_CB_PORT=1026"
- "IOTA_NORTH_PORT=4041"
- "IOTA_REGISTRY_TYPE=mongodb"
- "IOTA_MONGO_HOST=mongodb"
- "IOTA_MONGO_PORT=27017"
- "IOTA_MONGO_DB=iotagentjson"
- "IOTA_HTTP_PORT=7896"
- "IOTA_PROVIDER_URL=http://iot-agent:4041"
mongodb:
#default 4.4 - for perseo to work use 3.2
image: mongo
hostname: mongodb
container_name: db-mongo
ports:
- "27017:27017"
#command: --bind_ip_all --smallfiles
volumes:
- mongodb:/data
healthcheck:
test: |
host=`hostname --ip-address || echo '127.0.0.1'`;
mongo --quiet $host/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' && echo 0 || echo 1
interval: 5s
perseocore:
#:1.1.0
#:1.8.0
image: telefonicaiot/perseo-core
hostname: perseocore
container_name: perseo_core
ports:
- "8080:8080"
command: -perseo_fe_url perseo-fe:9090
perseo-fe:
#:1.5.0
#https://stackoverflow.com/questions/50645999/perseo-fe-docker-instance-fail-to-start
image: telefonicaiot/perseo-fe
hostname: perseo-fe
ports:
- "9090:9090"
depends_on:
- perseocore
#restart: on-failure
environment:
- PERSEO_MONGO_ENDPOINT=mongodb
- PERSEO_CORE_URL=http://perseocore:8080
- PERSEO_LOG_LEVEL=debug
- PERSEO_ORION_URL=http://orion:1026/v1/updateContext
1 ответ
POST /v1/updateContext/v2/op/update
не является допустимым маршрутом в открытом API Orion, так что это является причинойservice '/v1/updateContext/v2/op/update' not found
ошибка в журналах и ответ об ошибке 400.
Perseo FE не должен пытаться отправлять запросы на этот URL-адрес. Правильный должен бытьPOST /v2/op/update
.
Возможно, проблема связана с неправильной настройкой конечной точки Orion в конфигурации Perseo. Не могли бы вы отредактировать свой пост с вопросом, чтобы включить конфигурацию Perseo, которую вы используете, пожалуйста?