'TCP buffer issue when publishing data from ESP32 on to mqtt broker

We are currently working on a project that involves sending IMU sensor data over MQTT broker using ESP32 Wi-Fi module. We are sending the data every 100milliseconds. It is too fast, as it is the need of the project. We need realtime data.

Whenever the ESP32 publishes the data(message) onto the broker we don't see the updations at broker immediately. Then we found out the issue that TCP buffer was buffering 2/3 messages and was publishing them together on broker.

So the behavior we expect is when subscribed to MQTT broker topic, we should be getting one set of data every 100ms. But because of this buffering issue, we are getting 2/3 sets of data together after 200/300ms which is uneven.

We are using PubSub client for ESP32-MQTT publishing.

Have anyone faced such issue and know the solution to this ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source