Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No CMD attributes added when sending push commands (using endpoint) #1559

Open
mapedraza opened this issue Jan 25, 2024 · 8 comments
Open

No CMD attributes added when sending push commands (using endpoint) #1559

mapedraza opened this issue Jan 25, 2024 · 8 comments

Comments

@mapedraza
Copy link
Collaborator

mapedraza commented Jan 25, 2024

IoT Agent Node Lib version the issue has been seen with

4.1.0

Bound or port used (API interaction)

Southbound (Devices data API), Northbound (Provision API and NGSI Interactions)

NGSI version

NGSIv2

Are you running a container?

Yes, I am using a contaner (Docker, Kubernetes...)

Image type

normal

Expected behaviour you didn't see

No _info and _status added to the entity when sending push commands (using endpoint parameter in provision)

Steps to reproduce the problem

Group provision

curl --location 'http://localhost:4041/iot/services' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /test240125' \
--header 'X-Auth-Token: null' \
--header 'Content-Type: application/json' \
--data '{
    "services": [
        {
            "resource": "/iot/json",
            "apikey": "123456789100",
            "type": "dev",
            "cbHost": "http://orion:1026",
            "static_attributes": [
                {
                    "name": "operationalStatus",
                    "type": "Text",
                    "value": "ok"
                }
            ],
            "commands": []
        }
    ]
}'

Dev provision

curl --location 'http://localhost:4041/iot/devices' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /test240125' \
--header 'X-Auth-Token: null' \
--header 'Content-Type: application/json' \
--data '{
    "devices": [
        {
            "protocol": "IoTA-JSON",
            "explicitAttrs": false,
            "device_id": "dev2",
            "apikey": "123456789100",
            "entity_name": "dev2",
            "entity_type": "Device",
            "transport": "HTTP",
            "lazy": [],
            "commands": [ 
                {
                    "name": "ping",
                    "type": "command"
                }
            ],
            "endpoint": "https://webhook.site/5425edee"
        }
    ]
}'

Triggering cmd

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device' \
-H 'fiware-service: test' \
-H 'fiware-servicepath: /test240125' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : "123"
}'

Then, no _info and _status attributes added to CB.

Expected _status = DELIVERED if worked the HTTP request to be included into the entity in order to align with polling commands.

After confirming the command, this means the following request:

curl --location 'http://localhost:7896/iot/json/commands?k=123456789100&i=dev2' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{"ping":"ping_ok"}'

entity is updated with info and status attributes as follows:

    "ping_info": {
      "type": "commandResult",
      "value": "ping_ok",
      "metadata": {
        "TimeInstant": {
          "type": "DateTime",
          "value": "2024-01-25T10:09:23.144Z"
        }
      }
    },
    "ping_status": {
      "type": "commandStatus",
      "value": "OK",
      "metadata": {
        "TimeInstant": {
          "type": "DateTime",
          "value": "2024-01-25T10:09:23.144Z"
        }
      }
    }
@mapedraza mapedraza added the bug label Jan 25, 2024
@mapedraza mapedraza changed the title No CMD attributes added when sending push commands No CMD attributes added when sending push commands (using endpoint ) Jan 25, 2024
@mapedraza mapedraza changed the title No CMD attributes added when sending push commands (using endpoint ) No CMD attributes added when sending push commands (using endpoint) Jan 25, 2024
@AlvaroVega
Copy link
Member

AlvaroVega commented Jan 25, 2024

IMHO depending on what is done by https://webhook.site/5425edee, in my case a request-bin service the command_status in entity will be updated. In a default case, request-bin is receiving command and doing nothing, and then iotagent mark command_status as PENDING.

Which response is sending https://webhook.site/5425edee endpoint ? 200? 204?

@mapedraza
Copy link
Collaborator Author

It retruns a 200 code.

In any case, the <command>_status attribute should be present, changing the value according with the response (2XX, 4XX or timeout)

@AlvaroVega
Copy link
Member

AlvaroVega commented Jan 25, 2024

Is this URL right ?

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ring?type=Device' \
-H 'fiware-service: test' \
-H 'fiware-servicepath: /test240125' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : "123"
}'

@mapedraza ring or ping ?

@mapedraza
Copy link
Collaborator Author

@AlvaroVega ping, was a typo

@Madhu1029
Copy link
Contributor

Hi @mapedraza ,

I was trying to reproduce the issue to fix it. But i am facing error while triggering command.

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device' \
-H 'fiware-service: test' \
-H 'fiware-servicepath: /test240125' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : "123"
}'

Above API results into below error:

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device'
-H 'fiware-service: test'
-H 'fiware-servicepath: /test240125'
-H 'Content-Type: application/json'
-d '{
"type" : "command",
"value" : "123"
}'
{"error":"NotFound","description":"The requested entity has not been found. Check type and id"}

Could you please help me to reproduce the issue?

@mapedraza
Copy link
Collaborator Author

Hi @mapedraza ,

I was trying to reproduce the issue to fix it. But i am facing error while triggering command.

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device' \
-H 'fiware-service: test' \
-H 'fiware-servicepath: /test240125' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : "123"
}'

Above API results into below error:

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device'
-H 'fiware-service: test'
-H 'fiware-servicepath: /test240125'
-H 'Content-Type: application/json'
-d '{
"type" : "command",
"value" : "123"
}'
{"error":"NotFound","description":"The requested entity has not been found. Check type and id"}

Could you please help me to reproduce the issue?

Could you share your share the steps you used till arriving to that response? Please, share also IoT Agent and Context Broker version

@Madhu1029
Copy link
Contributor

Hi @mapedraza ,

I have followed below steps:
1. Group Provision

curl --location 'http://localhost:4041/iot/services' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /test240125' \
--header 'X-Auth-Token: null' \
--header 'Content-Type: application/json' \
--data '{
    "services": [
        {
            "resource": "/iot/json",
            "apikey": "4jggokgpepnvsb2uv4s40d59ov",
            "type": "dev",
            "cbHost": "http://localhost:1026",
            "static_attributes": [
                {
                    "name": "operationalStatus",
                    "type": "Text",
                    "value": "ok"
                }
            ],
            "commands": []
        }
    ]
}'

2. Device Provision

curl --location 'http://localhost:4041/iot/devices' \
--header 'Fiware-Service: test' \
--header 'Fiware-ServicePath: /test240125' \
--header 'X-Auth-Token: null' \
--header 'Content-Type: application/json' \
--data '{
    "devices": [
        {
            "protocol": "IoTA-JSON",
            "explicitAttrs": false,
            "device_id": "dev2",
            "apikey": "4jggokgpepnvsb2uv4s40d59ov",
            "entity_name": "dev2",
            "entity_type": "Device",
            "transport": "HTTP",
            "lazy": [],
            "commands": [ 
                {
                    "name": "ping",
                    "type": "command"
                }
            ],
            "endpoint": "http://localhost:3001"
        }
    ]
}'

3. Trigger Command

curl -L -X PUT 'http://localhost:1026/v2/entities/dev2/attrs/ping?type=Device' \
-H 'fiware-service: test' \
-H 'fiware-servicepath: /test240125' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : "123"
}'

After Step 3, I am facing below error:
{"error":"NotFound","description":"The requested entity has not been found. Check type and id"}

Note: I have started dummy IoT Devices configuration using below:

tutorial:
    image: quay.io/fiware/tutorials.context-provider
    hostname: iot-sensors
    container_name: fiware-tutorial
    networks:
        - default
    expose:
        - '3000'
        - '3001'
    ports:
        - '3000:3000'
        - '3001:3001'
    environment:
        - 'DEBUG=tutorial:*'
        - 'PORT=3000'
        - 'IOTA_HTTP_HOST=iot-agent'
        - 'IOTA_HTTP_PORT=7896'
        - 'DUMMY_DEVICES_PORT=3001'
        - 'DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov'
        - 'DUMMY_DEVICES_TRANSPORT=HTTP'

@mapedraza
Copy link
Collaborator Author

mapedraza commented May 27, 2024

Hi @mapedraza ,

I have followed below steps: 1. Group Provision

...

Note: I have started dummy IoT Devices configuration using below:

tutorial:
    image: quay.io/fiware/tutorials.context-provider
    hostname: iot-sensors
    container_name: fiware-tutorial
    networks:
        - default
    expose:
        - '3000'
        - '3001'
    ports:
        - '3000:3000'
        - '3001:3001'
    environment:
        - 'DEBUG=tutorial:*'
        - 'PORT=3000'
        - 'IOTA_HTTP_HOST=iot-agent'
        - 'IOTA_HTTP_PORT=7896'
        - 'DUMMY_DEVICES_PORT=3001'
        - 'DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov'
        - 'DUMMY_DEVICES_TRANSPORT=HTTP'

Hi @Madhu1029 . I am not able to see which version of Orion and IoTA you are using. Please, try with latest releases:

telefonicaiot/fiware-orion:3.12.0

and

telefonicaiot/iotagent-json:3.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants