Incomplete MQTT Messages with RUT142 and Modbus TCP

Hello Teltonika Community,

We are using the Teltonika RUT142 router to collect data from a PLC via Modbus TCP and send it to our MQTT broker (EMQX) every 10 seconds. However, we’ve been encountering an issue where MQTT messages are sometimes received incomplete, leading to broken data. This happens intermittently throughout the day.

Troubleshooting Steps Taken:

  1. Verified network stability between the PLC, router, and MQTT broker.
  2. Checked and adjusted MQTT Quality of Service (QoS) settings (tested with QoS 0, 1, and 2) — the issue persists.
  3. Changed the collection period for the PLC to 8 seconds and MQTT publish to 10 seconds, but the problem still occurs. I also noticed that if PLC collection period is at 5s and MQTT publish period at 10s then the Data to Server sends a double message to the MQTT Broker.
  4. Experimented with collection periods for the PLC being lower or higher than the sending interval for the Data to Server function, with no success.

Here are some photos of my configuration : :






Segment count is 33 because the modbus devices are 33 in total and i want to send all of them in a single JSON (grouped) every 10seconds in my MQTT Broker.

Question:

  1. Is it something wrong going on with my configuration?

  2. I’d like to better understand how the collection period from the router to the PLC impacts the Data to Server function. Specifically:

  • Is there a way to check logs or raw data collected directly from the PLC before it is sent to the server?
  • For example, is it possible to review files via SSH or through another method to identify issues or verify the integrity of the collected data?

Any advice or suggestions on resolving this intermittent issue or improving debugging would be greatly appreciated.

Thank you in advance!

Best regards,

Hello,

Thank you for reaching out.

  1. Configuration Advice:
    At first glance, your configuration appears correct. However, I would recommend aligning the periods for requesting data from the Modbus server device and sending it to the MQTT broker. For example, if the Modbus TCP server request period is shorter than the sending interval, the router may buffer data from the first request and send duplicate data when it reaches the server. Using the same interval for both operations should help avoid such issues.
  2. Checking Collected Data:
    Yes, you can verify the data collected from the Modbus server by accessing the database file stored on the router. This can be done via SSH:
  • Navigate to /var/modbus_db.
  • You can either examine the file directly or download it and open it using a database browser like SQLite to inspect the data for integrity or discrepancies.

Let me know if you need further assistance or have additional questions.

Best regards,

Hello Martynas,

First of all, I greatly appreciate your feedback and support.

I have been troubleshooting the issue of broken JSON messages with my RUT142 setup and have tried aligning the periods for requesting data from the Modbus server and sending it to the MQTT Broker, but unfortunately, without success.

Here are the approaches I have tested so far:

  1. Matching the requesting and sending periods.
  2. Setting the requesting period to be longer than the sending period (as suggested in this discussion: RUT142 Broken JSON to Broker).
  3. Setting the requesting period to be shorter than the sending period.

Despite trying these configurations, the issue persists. The RUT142 has been installed for at least two months now, and the broken JSON messages continue to occur regularly.

I would greatly appreciate your insights or suggestions for resolving this issue.

Best regards

Hello Martynas,

To provide more context, I have attached a screenshot that highlights the issue:

The JSON message is supposed to contain 34 keys (V1 ~ V34), each corresponding to a value. However, as you will notice in the logs:

  • At 11:34:48:076, we received only the first half of the message.
  • At 11:34:58:083, we received the second half of the same message.

This results in broken and incomplete JSONs.

For comparison, the correct message structure can be seen in the log at 11:35:08:127, where the entire JSON is received properly in one message.

I hope this additional information helps clarify the issue. I would greatly appreciate your insights or any suggestions for resolving this behavior.

Best regards,

Hello,

Thank you for providing more details.

For troubleshooting purposes, I would suggest trying the following configuration changes:

  1. Set both the data to server and Modbus request periods to 60 seconds.
  2. Set the timeout in the Modbus device configuration to 10 seconds (or leave it at the default value of 5 seconds).
  3. Ensure the number of timeouts is left at its default value of 0.

Please monitor the behavior after making these changes and let me know if the issue persists. If that helps decrease the data sending and requesting periods to your needed values, check if the same behavior reappears.

Best Regards,

Hello Martynas,

Thank you for your recommendations. I followed the configuration changes you suggested:

  1. Set both data to server and Modbus request periods to 60 seconds.
  2. Updated the timeout in the Modbus device configuration to 10 seconds.
  3. Left the number of timeouts at its default value of 0.

Unfortunately, as shown in the following screenshot by monitoring the topic in MQTTX software, the issue persists.

You can see from the logs that the JSON messages are still being split into multiple parts. This behavior continues to occur, even with the adjustments.

Please let me know if you have any additional suggestions or if there are further steps I can try to resolve this.

Best regards,