thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.76k stars 846 forks source link

[BUG] some messages failed to report #1579

Closed ppmll closed 2 weeks ago

ppmll commented 3 weeks ago

Describe the issue I think this is a bug but I am not sure. When more than one timestamped messages sent to the storage for the same device, the gateway only reports the last one to thingsboard, I've made some debug and discovered that a method called _split_message is called with all the messages and just one is returned before it is beeing publish to mqtt.

Configuration (Attach your configuration file) Not needed

Connector name (If you need help with some connector/converter): I am using a simple custom connector that reads a specific file, each line of that file has a specific timestamp, it is then sending to the storage using gateway.send_to_storage

Error traceback (If it was raised): Not raised

Versions (please complete the following information):

imbeacon commented 3 weeks ago

Hi @ppmll,

You are particularly right, the gateway collects and send only last value from the converted data, it is done in the same way as implemented in ThingsBoard itself - data with the same ts cannot exists. To avoid this situation - you can add ts to your data and save ConvertedData with TelemetryEntry and ts, this will avoid overwriting of the data.

ppmll commented 3 weeks ago

Hi @imbeacon, I am sorry, maybe I did not explain correctly, what I mean is that if I send 3 consecutive messages with different timestamps only the last one is sent to thingsboard, please see the folllowing example: Input of the _split_message method: image

Only last one was sent to thingsboard.

Thanks.

imbeacon commented 3 weeks ago

I see and able to reproduce, let you know after fixing this point.

imbeacon commented 2 weeks ago

Hi @ppmll,

I have made some fix for this data loss, please try new version of the sdk - https://github.com/thingsboard/thingsboard-python-client-sdk/releases/tag/1.10.10, or the gateway from the master branch.

ppmll commented 2 weeks ago

It seems ok now, thank you.