Atos-Research-and-Innovation / IoTagent-LoRaWAN

FIWARE IoT Agent for LoRaWAN protocol (with CayenneLpp and CBOR data models)
https://fiware-lorawan.readthedocs.io/en/latest/
Other
34 stars 40 forks source link

IoTAgent not responding when sending configuration provisioning #97

Closed FlorianCodes closed 2 years ago

FlorianCodes commented 4 years ago

Hi,

I am not sure if this is an issue with the IoTAgent itself or with the way I am using it. Please correct me if I am doing something wrong.

I am using the provided docker container (image ioeari/iotagent-lora:latest with ID 9868f18157d4). After a successful startup, I try to configure the southport using cURL with the Configuration Provisioning as described in the docs.

According to the logs of the IoTAgent, the device group could not be found and therefore has been created. I can confirm the creation by having a look into the Mongo database.

However, the IoTAgent does not respond to my cURL request. The cURL terminal gets unresponsive and waits for a response, until the session times out.

This is unexpected behavior, because I expect the IoTAgent to respond with a HTTP 2xx status code in case of success or with a HTTP 4xx status code in case of failure.

I am not sure if this is important: The loraserver.io instance stated in the request does not yet exist.

My questions are: Why does the IoTAgent not respond? How can I fix this?

In the following I will show my cURL request, its output and the IoTAgent logs.

My cURL request is:

curl -i -v \
    "http://localhost:4041/iot/services" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -H "Fiware-Service: service" \
    -H "Fiware-ServicePath: /servicepath" \
    -d '
{
    "services": [
        {
            "entity_type": "entity_type",
            "apikey": "my_api_key",
            "resource": "0123456789abcdef",
            "attributes": [
                {
                    "object_id": "age",
                    "name": "age_in_days",
                    "type": "Number"
                }
            ],
            "internal_attributes": {
                "lorawan": {
                    "application_server": {
                        "host": "my-loraserver-instance.de",
                        "username": "lnsuser",
                        "password": "lnspwd",
                        "provider": "loraserver.io"
                    },
                    "app_eui": "0123456789abcdef",
                    "application_id": "my_application",
                    "application_key": "0123456789abcdef0123456789abcdef",
                    "data_model": "application_server"
                }
            }
        }
    ]
}'

The cURL output is:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4041 (#0)
> POST /iot/services HTTP/1.1
> Host: localhost:4041
> User-Agent: curl/7.58.0
> Content-Type: application/json
> Accept: application/json
> Fiware-Service: service
> Fiware-ServicePath: /servicepath
> Content-Length: 977
> 
* upload completely sent off: 977 out of 977 bytes

The IoTAgent logs are:

fiware-iotagent-lora | {"op":"IoTAgentNGSI.GenericMiddlewares","time":"2020-05-14T13:56:00.000Z","lvl":"DEBUG","msg":"Request for path [/iot/services] from [localhost:4041]"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.GenericMiddlewares","time":"2020-05-14T13:56:00.000Z","lvl":"DEBUG","msg":"Body:\n\n{\n \"services\": [\n {\n \"entity_type\": \"entity_type\",\n \"apikey\": \"my_api_key\",\n \"resource\": \"0123456789abcdef\",\n \"attributes\": [\n {\n \"object_id\": \"age\",\n \"name\": \"age_in_days\",\n \"type\": \"Number\"\n }\n ],\n \"internal_attributes\": {\n \"lorawan\": {\n \"application_server\": {\n \"host\": \"my-loraserver-instance.de\",\n \"username\": \"lnsuser\",\n \"password\": \"lnspwd\",\n \"provider\": \"loraserver.io\"\n },\n \"app_eui\": \"0123456789abcdef\",\n \"application_id\": \"my_application\",\n \"application_key\": \"0123456789abcdef0123456789abcdef\",\n \"data_model\": \"application_server\"\n }\n }\n }\n ]\n}\n\n"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.DeviceGroupService","time":"2020-05-14T13:56:00.003Z","lvl":"DEBUG","msg":"Creating new set of 1 services"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.DeviceGroupService","time":"2020-05-14T13:56:00.004Z","lvl":"DEBUG","msg":"validateGroup {\"apikey\":\"my_api_key\",\"resource\":\"0123456789abcdef\",\"attributes\":[{\"object_id\":\"age\",\"name\":\"age_in_days\",\"type\":\"Number\"}],\"type\":\"entity_type\",\"internalAttributes\":{\"lorawan\":{\"application_server\":{\"host\":\"my-loraserver-instance.de\",\"username\":\"lnsuser\",\"password\":\"lnspwd\",\"provider\":\"loraserver.io\"},\"app_eui\":\"0123456789abcdef\",\"application_id\":\"my_application\",\"application_key\":\"0123456789abcdef0123456789abcdef\",\"data_model\":\"application_server\"}},\"service\":\"service\",\"subservice\":\"/servicepath\"}"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.MongoDBGroupRegister","time":"2020-05-14T13:56:00.004Z","lvl":"DEBUG","msg":"Looking for group params [\"resource\",\"apikey\"] with queryObj {\"resource\":\"0123456789abcdef\",\"apikey\":\"my_api_key\"}"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.MongoDBGroupRegister","time":"2020-05-14T13:56:00.012Z","lvl":"DEBUG","msg":"Device group for fields [[\"resource\",\"apikey\"]] not found: [{\"resource\":\"0123456789abcdef\",\"apikey\":\"my_api_key\"}]"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.Alarms","time":"2020-05-14T13:56:00.013Z","lvl":"ERROR","msg":"Raising [MONGO-ALARM]: {\"name\":\"DEVICE_GROUP_NOT_FOUND\",\"message\":\"Couldn\t find device group\",\"code\":404}"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.DeviceGroupService","time":"2020-05-14T13:56:00.014Z","lvl":"DEBUG","msg":"generateDuplicateHander error [object Object] and foundGroup undefined"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.MongoDBGroupRegister","time":"2020-05-14T13:56:00.026Z","lvl":"DEBUG","msg":"Storing device group with id [5ebd4df01e2725000874de9f], type [entity_type], apikey [my_api_key] and resource [0123456789abcdef]"} fiware-iotagent-lora | {"op":"IoTAgentNGSI.Alarms","time":"2020-05-14T13:56:00.037Z","lvl":"ERROR","msg":"Releasing [MONGO-ALARM]"}

ICollantes commented 2 years ago

Hi, the provisioning does not work because "application_server" data does not exist. Lorawan Agent try to connect to the mqtt server and found nothing. The device is registered in mongo db but fails when creating the connection. If you want to test without a real sensor you can do it with the procedure described in https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/blob/master/docs/users_manual.md#testing-the-lorawan-iot-agent-with-dummy-devices or creating a real instance in loraserver.io. There is no http response but a curl response

Regards, Ignacio.