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:
Verified network stability between the PLC, router, and MQTT broker.
Checked and adjusted MQTT Quality of Service (QoS) settings (tested with QoS 0, 1, and 2) — the issue persists.
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.
Experimented with collection periods for the PLC being lower or higher than the sending interval for the Data to Server function, with no success.
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:
Is it something wrong going on with my configuration?
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.
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.
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.
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:
Matching the requesting and sending periods.
Setting the requesting period to be longer than the sending period (as suggested in this discussion: RUT142 Broken JSON to Broker).
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.
For troubleshooting purposes, I would suggest trying the following configuration changes:
Set both the data to server and Modbus request periods to 60 seconds.
Set the timeout in the Modbus device configuration to 10 seconds (or leave it at the default value of 5 seconds).
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.
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.