BG95: MQTT client cache file

Hi,

While developing on our BG95 device, I sometimes need to change the MQTT thingName. We connect to AWS using HTTPS/TLS.

After some time, the EFS file ‘ext:/datatx/mqtt/mqtt_restore_persist’ has grown in size to almost 1MB. While looking at its contents, there seem to be a ~20 KB sections of 0’s for each thingName we used before.

Can someone please explain when is this file used? Is it safe to remove it? I’ve noticed no degradation after the removal, but I’d better be certain about it.

Thanks in advance!
Michael

Hi,
Please use AT+QGMR to check the specific version and model.

Hi Tabor,

Thanks for the response. This is what my unit is running:

AT+QGMR
BG95M3LAR02A03_01.014.01.014

Is your module an open scheme module or a standard scheme module?

I’m not quite sure what you mean by open or standard. Can you please elaborate on that?

The MQTT connection is configured with the help of qapi_Net_MQTT_Config_t type and qapi_Net_MQTT_Connect method. The field client_id is the one that we are seeing in the persistent file.

ext:/datatx/mqtt/mqtt_restore_persist,Does this file keep getting bigger?

Yes. Every time the device uses a new client_id, this file grows with ~20KB. So, after the ID has been changed 20 times, the file is around half megabytes big. It doesn’t grow after each connection, just after the change of the client_id.

Hi,
Excuse me, why is the new client_id used? Normally, a device only needs a client_id, and only one id is bound to it later. This file is used to hold information about the mqtt connection, and if the id is changed, a new file is generated. From your description, it seems that the new mqtt connection information was added at the end of the original file, causing the file to become larger.

Correct. This is an experimental device with changed client_id.

The question here is

  1. Why does this file stay after the MQTT connection is closed?
  2. What is the way to prevent it from being added or “flush” when more space is needed?
  3. Is it safe to remove this file without affecting the MQTT functionality?

There seems to be no information about this persistent cache in the documentation, that’s why I raise it here.
Hint: please add it to the documentation in the future :slight_smile:

Do you need to change the new client_id frequently for this device? mqtt_restore_persist This file is used to hold information about the mqtt connection context. It is a necessary file and deletion will have an impact.

I’ll relay your request to our internal R&D.

@tabor.tang-Q Thank you for your assistance.

Yes, this device changes ID as a part of our release testing, so it’s approximately once every 2 weeks. I haven’t noticed any degradation in MQTT functionality as a result of this file’s removal, but it may be masked by something else, of course.

Will a new file be generated when changing the new ID after the file is deleted?

@tabor.tang-Q Yes, the file is recreated, and only contains the information about the current client_id (about 20KB)

You can delete the previous file when changing the ID.

Thanks for the confirmation.

Is there any way to do it via an AT command or use a setting that will prevent it from being created, in case we are not doing any persistent MQTT sessions?

This is a required file that is generated after the connection is established and cannot be stopped.