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

Bugs? #21

Closed diego-gv closed 5 years ago

diego-gv commented 5 years ago

I don't know if it's a mistake, but I think I have to report it.

The situation is that when I delete a device provisioning, the IoTAgent LoRaWAN remains connected to the MQTT broker. In this way, the IoTAgent continues to receive the topic updates.

info: New message in topic application/1/node/3738363779378704/rx
time=2018-12-12T14:30:00.110Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=test | subsrv=/test | msg=Looking for entity with id [clon-miniweather]. | comp=IoTAgent
time=2018-12-12T14:30:00.115Z | lvl=DEBUG | corr=n/a | trans=n/a | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=test | subsrv=/test | msg=Entity [clon-miniweather] not found. | comp=IoTAgent
time=2018-12-12T14:30:00.115Z | lvl=ERROR | corr=n/a | trans=n/a | op=IoTAgentNGSI.Alarms | srv=test | subsrv=/test | msg=Raising [MONGO-ALARM]: undefined | comp=IoTAgent
error: Error getting IoTA device object {"name":"DEVICE_NOT_FOUND","message":"No device was found with id:clon-miniweather","code":404}

Wouldn't it be more correct if the IoTAgent stopped the connection with the MQTT broker?

Regards, Diego

diego-gv commented 5 years ago

Hello again @dcalvoalonso

On the other hand, I'm trying to use the service provisioning for subscribe my IoTAgent to the Mosquitto Broker.

First, I send a service provisioning without problems, the iotagent save the provisioning and it wait to new messages in topic. In first message received of topic, the IoTAgent create a device provisioning and it update that device in the Orion Context Broker.

The problem is that in the next message received by the IoTAgent, this generate the next messages and it don't update the entity in the Orion Context Broker.

info: New message in topic application/1/node/3738363779378704/rx
info: LoRaWAN device unprovisioned

8-12-13T12:34:57.773Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=test | subsrv=/test | msg=Looking for entity params ["resource","apikey"] | comp=IoTAgent

8-12-13T12:34:57.809Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=test | subsrv=/test | msg=Looking for entity with id [clon-miniweather]. | comp=IoTAgent
error:  name=DUPLICATE_DEVICE_ID, message=A device with the same pair (Service, DeviceId) was found:clon-miniweather, code=409
info: New message in topic application/1/node/3738363779378704/rx
info: LoRaWAN device unprovisioned

8-12-13T12:41:03.453Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=test | subsrv=/test | msg=Looking for entity params ["resource","apikey"] | comp=IoTAgent

8-12-13T12:41:03.483Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=test | subsrv=/test | msg=Looking for entity with id [clon-miniweather]. | comp=IoTAgent
error:  name=DUPLICATE_DEVICE_ID, message=A device with the same pair (Service, DeviceId) was found:clon-miniweather, code=409
info: New message in topic application/1/node/3738363779378704/rx
info: LoRaWAN device unprovisioned

8-12-13T12:47:09.314Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBGroupRegister | srv=test | subsrv=/test | msg=Looking for entity params ["resource","apikey"] | comp=IoTAgent

8-12-13T12:47:09.349Z | lvl=DEBUG | corr=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | trans=7594c9bf-402b-4855-88a3-97dfa5f3aab4 | op=IoTAgentNGSI.MongoDBDeviceRegister | srv=test | subsrv=/test | msg=Looking for entity with id [clon-miniweather]. | comp=IoTAgent
error:  name=DUPLICATE_DEVICE_ID, message=A device with the same pair (Service, DeviceId) was found:clon-miniweather, code=409

Regards, Diego

reitsma commented 5 years ago

The AbstractAppService attempts to maintain a list of devices. The problem is that this class is not aware of devices being provisioned or deprovisioned by calls to the nodelibagent service or by automatic provisioning from a configuration. Only after a restart of the agent it works properly, because the list is initialized on startup of the agent.

Preferably we need a callback from the nodelib library when a device is provisioned or deprovisioned, but I can't find such a call. Does it exists?

Is the additional device list really necessary to maintain the MQTT subscriptions?

dcalvoalonso commented 5 years ago

@garvi-x With respect to https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/issues/21#issue-390257314:

Wouldn't it be more correct if the IoTAgent stopped the connection with the MQTT broker?

I have opened a PR to iotagent-node-lib to fix this issue: https://github.com/telefonicaid/iotagent-node-lib/pull/735. Once it is merged, I will fix this in this agent.

dcalvoalonso commented 5 years ago

Regarding https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/issues/21#issuecomment-446956308:

The problem is that in the next message received by the IoTAgent, this generate the next messages and it don't update the entity in the Orion Context Broker.

It should have been fixed with https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/pull/27. @garvi-x , could you please check if it works now?

BTW, next time it would be better to create an issue for each bug. ;)

dcalvoalonso commented 5 years ago

https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/issues/21#issue-390257314 should be fixed with https://github.com/Atos-Research-and-Innovation/IoTagent-LoRaWAN/pull/34

dcalvoalonso commented 5 years ago

@garvi-x @reitsma could you please confirm that this issue can be closed?

diego-gv commented 5 years ago

Hi @dcalvoalonso,

Confirm that this issue can be closed by my part.

Just a note, when you want to delete a service provisioning as with a device provisioning (without indicate resource and apikey in the parameters) the IoTAgent returns the following message:

{
    "name": "MISSING_HEADERS",
    "message": "Some headers were missing from the request: [\"resource\",\"apikey\"]"
}

The right message would be:

{
    "name": "MISSING_PARAMETERS",
    "message": "Some parameters were missing from the request: [\"resource\",\"apikey\"]"
}

Thanks for all Daniel :))

dcalvoalonso commented 5 years ago

Thanks @garvi-x. I will try to fix this in https://github.com/telefonicaid/iotagent-node-lib

dcalvoalonso commented 5 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: