[ZBX-25236] Agent2 - MQTT timeout while subscribing Created: 2024 Sep 16  Updated: 2025 Feb 17  Resolved: 2025 Feb 17

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent2 plugin (G)
Affects Version/s: 7.0.2, 7.0.3
Fix Version/s: 6.0.39rc1, 7.0.10rc1, 7.2.4rc1, 7.4.0alpha1

Type: Problem report Priority: Trivial
Reporter: Timo Hein Assignee: Stanislavs Jurgensons
Resolution: Fixed Votes: 2
Labels: agent, items, performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian 12, Zabbix 7.0.3, Mosquitto 2.011, Zabbix Agent 2 7.0.3


Attachments: Text File Agent2Log.txt     PNG File Screenshot1.png     PNG File image-2024-09-23-12-46-06-448.png     PNG File image-2024-09-23-13-13-44-282.png     File mqtt01.pcap     Text File ping.txt     File zabbix_agent2.conf     Zip Archive zabbix_agent2.zip     File zabbix_server.7z     File zabbix_server.conf     File zbx_export_hosts.yaml     File zbx_export_templates (1).yaml    
Team: Team INT
Sprint: Support backlog
Story Points: 4

 Description   

Issue already posted in the zabbix forum:

https://www.zabbix.com/forum/zabbix-help/489802-agent2-mqtt-plugin-issue-time-out-while-subscribing

Steps to reproduce:

  1. template with a master item (use postprocessing to format the data) that subscribe to an mqtt topic with 40+ items
  2. child items that depend on that master item (use postprocessing to extract the data)
  3. have two or more hosts which apply this template
  4. MQTT broker, may be on the same or a different system

See template file...

Result:
See screenshot...
See log file...

Remarks:

The issue exists also in lower versions.

There the amount of items per host, before having this issue, is much higher (approx. 1000).

 



 Comments   
Comment by Kamil Florowski (Inactive) [ 2024 Sep 23 ]

Hi,

Since I was not able to reproduce it, could you provide more precise details regarding your config (hosts, items).

Also couple of questions to clarify:

  • Do the Zabbix server's logs say anything else that can be helpful to debug the issue?
  • Have you tried playing with PluginTimeout as suggested in forum thread?
  • When exactly the error occurs? To how many topics are you subscribing? Is that the issue occurring if only more than 2 hosts are involved?
  • Not sure if related, but what is the example input sent to the topic? Is the preprocessing step extracting json value correct? Seems like
    $.["InterfaceOrder.Interface.WMS.IndexEnd.PLCSetpoint"] does not follow the syntax from here: https://www.zabbix.com/documentation/current/en/manual/config/items/preprocessing/jsonpath_functionality
Comment by Timo Hein [ 2024 Sep 23 ]
  • Do the Zabbix server's logs say anything else that can be helpful to debug the issue?

-> the only messages I found was something like this, but I can issue another test if you want

  • Have you tried playing with PluginTimeout as suggested in forum thread?

-> Yes, I tried this, but it seems, that it has no effect or the timeout which is max. 30 seconds is not high enough.

  • When exactly the error occurs? To how many topics are you subscribing? Is that the issue occurring if only more than 2 hosts are involved?

-> It happens right after the start of the agent.

-> From 1 to some 100

-> it seems, that if you have more than 5 or in lower versions 7 hosts, the number of topics is no longer relevant

-> I tried to extract the data like $.["InterfaceOrder.Interface.WMS.IndexEnd.PLCSetpoint"].['value'] but this doesn't work
I get the following error message "cannot extract value from json by path "$.["InterfaceOrder.Interface.WMS.IndexEnd.PLCSetpoint"]['value']": no data matches the specified path". So I decided to add an additional preprocessing step "$.value"

Comment by Kamil Florowski (Inactive) [ 2024 Sep 23 ]

Could you try to capture more detailed logs with setting the DebugLevel to 5. You can try checking that both on agent and server side.

Thanks

Comment by Timo Hein [ 2024 Sep 24 ]

Hello,

I found this in the agent2.log:

2024/09/24 07:53:47.528091 [MQTT] cannot subscribe topic 'VSW02/#' to [tcp://10.83.170.106:1883]: timed out while subscribing

and this in server.log

 1033:20240924:075348.312 zbx_substitute_functions_results() expression[0]:'{33577}=1' => 'ERROR(Cannot evaluate function last(/VSW02/InterfaceStatus.Interface.EmergencyStop,#1): item is not supported.)=1'

 

I attached the files as zip.

 

Comment by Kamil Florowski (Inactive) [ 2024 Sep 26 ]

Hi,

could you please provide the output of 

nc -zv 10.83.170.106 1883

from the agent where you are getting the error logs.

Comment by Timo Hein [ 2024 Sep 26 ]

Hi,

The output of  "nc -zv 10.83.170.106 1883" is

pa@ZabbixTest:/var/log/zabbix$ nc -zv 10.83.170.106 1883
10.83.170.106: inverse host lookup failed: Unknown host
(UNKNOWN) [10.83.170.106] 1883 open

Comment by Kamil Florowski (Inactive) [ 2024 Sep 27 ]

We have tried to reproduce the issue, but with no succes, could you please provide more details on how to reproduce it?

Comment by Timo Hein [ 2024 Sep 27 ]

Would it help you if I send you the configuration files from the server, the agent and an export of the hosts of my system?

Comment by Kamil Florowski (Inactive) [ 2024 Sep 27 ]

That might be helpful

Comment by Timo Hein [ 2024 Sep 27 ]

I uploaded the files.

Just for information: The issue mostly appears when you restart the agent2 or reboot the system where the agent2 runs on.

What I observed is, if you add one host after another into Zabbix the issue does not appear. But as soon as you do what I mentioned above it will show up.

Comment by Kamil Florowski (Inactive) [ 2024 Sep 30 ]

Hi,

Still unable to reproduce, could you provide the steps to reproduce on clean Zabbix instance with minimum hosts/templates involved (since you mention that the broker can be on the same system, I would like to see the error in this scenario)?

Some additional questions:

Comment by Timo Hein [ 2024 Sep 30 ]

Hi,

I indeed had the issue also on a fresh installed system. Nevertheless I will prepare a separate clean installed test system for this.

I will try to install Zabbix, NodeRed and Mosquitto on the same VM. I'll keep you informed when I'm ready.

 

  • yes the MQTT broker is also installed on Debian 12
  • this is, because the Zabbix on the test system was formerly at version 6 (here the configuration wasn't separated) 
    • Question from my side: is this configuration really needed, since you can pass most of these parameters with host macros?
Comment by Kamil Florowski (Inactive) [ 2024 Sep 30 ]

Thanks, I will wait for your follow-up message.

Regarding your question, no it should not be needed so you can remove them form agent config.

Comment by Timo Hein [ 2024 Oct 01 ]

Hello, 

here are my test results:

 

Test1 - New Testsystem (clean install)
-----------------------------
Zabbix Server 7.0.4
Zabbix Frontend 7.0.4
Zabbix Agent2 7.0.4

10 Hosts with 2 items
All on one VM (NodeRed, Mosquitto, Zabbix)

Result=OK
----------------------------

Test2 - Old Testsystem (Updated to 7.0.4)
-----------------------------
Zabbix Server 7.0.4
Zabbix Frontend 7.0.4
Zabbix Agent2 7.0.4

Same hosts as before

Result=NOK
----------------------------

Test3 - New Testsystem
-----------------------------
Zabbix Server 7.0.4
Zabbix Frontend 7.0.4
Zabbix Agent2 7.0.4

10 Hosts with 2 items
Added 7 hosts where the mqtt broker is installed on another VM.

Result=NOK
Remark also hosts where the mqtt broker is installed locally now have errors.

---------

It seems that if the MQTT-Plugin needs to work outside its host (over network) it has problems with the communication.

I changed the Mosquitto config so that there is no difference. But this didn't help.

Comment by Kamil Florowski (Inactive) [ 2024 Oct 08 ]

I followed the above steps but still could not reproduce it. Could you capture the traffic from/to mqtt broker:
tcpdump -npi any -s 0 -w /file/path.pcap host x.x.x.x

You might want to also execute the below to check if packets are dropped, delayed at the point of timeouts:

LC_ALL=C ping -s 1400 -c 100 -i 0.01 <broker_ip>

Comment by Timo Hein [ 2024 Oct 14 ]

Sorry for the late answer. I was out of office last week.

I've put the files you requested.

During the recording of the pcap-file I restarted the agent.

Comment by Timo Hein [ 2024 Oct 24 ]

Today I tested the 7.0.5 version and I had the same issue.

Zabbix Server 7.0.5
Zabbix Frontend 7.0.5
Zabbix Agent2 7.0.5

 

Comment by Timo Hein [ 2024 Nov 05 ]

Hello,

Do you have any news? May I do something so that you can

better reproduce the problem?

Thanks

Comment by Timo Hein [ 2024 Nov 12 ]

Hello,

from the Zabbix-Forum I received that hint.

https://www.zabbix.com/forum/zabbix-help/489802-agent2-mqtt-plugin-issue-time-out-while-subscribing#post493901

https://www.zabbix.com/forum/zabbix-help/456267-mqtt-plugin-in-zabbix-agent-2-subscribe-was-broken-by-timeout/page2

It seems to be a known issue. Please consider to fix it.

Comment by Christian Westebbe [ 2024 Dec 10 ]

Hello,

is there any progress on this one? We started using mqtt.get  This is a perfect way for us. But we have exactly the same porblems (timed out while subscribing/inalid update interval)

Our Setup:

  • Zabbix Server 7.06
  • Zabbix Agent 2 7.0.6 (Plugin communication protocol version is 6.4.0.
  • Zabbix Frontend 7.0.6

Thanks in advance!

Christian

Comment by Stanislavs Jurgensons [ 2025 Feb 10 ]

Fixed in:

Generated at Fri Feb 28 00:21:07 EET 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.