thingspeak mqtt has big delay

Dirk Steinkopf on 5 Nov 2021 (Edited on 5 Nov 2021)
Latest activity Reply by Vinod on 10 Nov 2021

Hello,

I am sending mqtt values from esp8266 devices to different channels - e.g. https://thingspeak.com/channels/1182897

The values are sent correctly and also show up on the channel's page correctly and quickly in time.

But mqtt receivers are getting the data with a varying long delay. Often the delay is 1h, so I first thought, this could be a time zone problem. But that's not the case.

I tried two different mqtt clients: Both get the values at the same (late time): E.g. when I now get a value from channels/1182897/subscribe/fields/field3 and look into the history of values (using "Data Import/Export") then this value can be found 20 minutes up to 1 hour ago. This can also be confirmed when looking into the device's logs.

What could I do to be up-to-date with my values? Thank you very much. Dirk

Dirk Steinkopf
Dirk Steinkopf on 5 Nov 2021

Now, I changed the main subscriber to use the new mqtt3 while leaving the publishers untouched (using the old mqtt).

This seems to have solved the problem by itself: Got current values for about 5 Minutes. - Switching back to the old broker resulted in getting delayed values again. Using the new broker still brings me up-to-date values.

Thank you for the hint to switch to the new broker. I am aware that I also have to switch the other devices.

Do you have an explanation for that? Is the old broker overloaded?

Vinod
Vinod on 5 Nov 2021

We're strongly recommending moving over to the new MQTT broker @ mqtt3.thingspeak.com.

The subscribers on the legacy MQTT service (mqtt.thingspeak.com) appear to be experiencing a delay between when the channel is updated and the subscriber receiving the message. We're looking into this. Note however that the legacy service is on a deprecation path.

Vinod
Vinod on 10 Nov 2021

The delay in the legacy MQTT system is resolved (a stuck node had to be restarted). The recommendation is still to use the new broker at mqtt3.thingspeak.com, which it appears both users on this thread were able to migrate to with minimal code changes.

Dirk Steinkopf
Dirk Steinkopf on 5 Nov 2021

I am still using mqtt.thingspeak.com. Thank you for reminding me to switch.

Could switching to mqtt3 improve the delay problem?

Do I have to switch all publishers and subscribers at once? Or are messages sent from one broker to the other?

Vinod
Vinod on 8 Nov 2021

I'd recommend switching both publishers and subscribers to use mqtt3.thingspeak.com. It is more efficient and performant for your device as well.

Jacques van der Mescht
Jacques van der Mescht on 9 Nov 2021

Sorry to hi-jack the thread. I also have delays on the old mqtt.thingspeak.com. But if I change to mqtt3.thingspeak, my data is not published. What else must be changed?

Vinod
Vinod on 9 Nov 2021 (Edited on 9 Nov 2021)

Take a look at the updated documentation and examples here. The changes required are very minor.

Jacques van der Mescht
Jacques van der Mescht on 9 Nov 2021

It is working now!!! Thanks!! It was the format of the topic. Had to remove API key.

Dirk Steinkopf
Dirk Steinkopf on 9 Nov 2021

I went through the documentation and examples for subscribers and publishers.

The changes for one of my subscribers are for example: use client-id from registration instead of a random one; remove the write API key at the end of the topic (see my code: https://gitlab.steinkopf.net/iot/bme280ondisplay/-/commit/ecfd94ad29aafb959c2b2382bfb6180d3214f756)

The changes for the subscriber are even simpler: I just changed the DNS name to mqtt3...

Vinod
Vinod on 5 Nov 2021

Are you sending data to mqtt3.thingspeak.com or the legacy MQTT interface?

Tags