简体   繁体   中英

Error in updating entities with Perseo in FIWARE

I am using Perseo , trying to define a rule that update an entity's attribute by using this post request to 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"
}
]
}
}
}'

But when I change the temperature using this POST request to IoT agent:

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"}]}*

but entity won't update and this error shows in the logs:

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

why there is 400 error in here?

Ps:

here is the entity defined for temperature:

{
     "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"}
     ]
   }

Edited:

Here is the configuration for orion and perseo front and core:

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

POST /v1/updateContext/v2/op/update is not a valid route in the Orion exposed API, so that is the cause of the service '/v1/updateContext/v2/op/update' not found error in logs and the 400 error response.

Perseo FE shouldn't be trying to send requests to that URL. The right one should be POST /v2/op/update .

Maybe the problem is due to some missconfiguration of the Orion endpoint in the Perseo's configuration. Could you edit your question post to include the Perseo's configuration you are using, please?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM