Lenses MQTT Source Connector空闲时未向Mosquitto Broker发送PINGREQ导致连接异常的问题排查与配置咨询
Great catch on narrowing down the issue to missing PINGREQ packets—that’s exactly the root cause here. Let’s walk through what’s going on and how to fix it:
Core Context
Per the MQTT protocol specification, a client must send a PINGREQ packet to the broker if no other messages (publish, subscribe, etc.) are sent within the configured keep-alive interval. This tells the broker the connection is still active, and vice versa. Your observation that other clients send PINGREQ correctly confirms the broker isn’t the issue—it’s the connector’s implementation of this protocol requirement.
Solutions to Enforce PINGREQ
Check for an explicit auto-ping configuration
Some MQTT client connectors (including those built on Eclipse Paho, which many Kafka Connect MQTT sources use) have a hidden or optional setting to enable automatic PINGREQ handling. Look for a configuration property likemqtt.auto.pingormqtt.enable.keep.alivein your connector’s settings. If it exists, set it totrue—this forces the connector to send PINGREQ packets during idle periods, even if it doesn’t detect internal activity.Adjust keep-alive and ping interval offsets
Even if you set the keep-alive to 10 minutes, try adding a separatemqtt.ping.intervalproperty (if supported) set to a value slightly less than the keep-alive interval (e.g., 9 minutes). This ensures the connector sends the PINGREQ before the broker’s timeout window closes, preventing the connection from being dropped silently.Verify clean session behavior
If your connector usesmqtt.clean.session=true, the broker will discard the client session immediately after detecting a timeout. Try settingmqtt.clean.session=false—this keeps the session alive on the broker side, and even if the connection drops temporarily, the connector can re-establish it without needing a full restart. Note that this may require handling retained messages or pending subscriptions carefully.Upgrade the connector version
This could be a known bug in older versions of the Lenses MQTT Source Connector. Check the official release notes for any fixes related to keep-alive or PINGREQ handling, and upgrade to the latest stable version. Many connector issues like this are resolved in newer releases.
What If None of These Work?
If the connector still doesn’t send PINGREQ packets after trying the above, it’s possible the connector’s implementation is missing this core protocol logic. In that case:
- Review the connector’s official documentation to confirm if PINGREQ handling is supposed to be automatic.
- Reach out to the Lenses support team or check their community forums for similar reported issues.
- If you’re comfortable with code, inspect the connector’s source (if open-source) to see if the keep-alive/PINGREQ logic is properly implemented.
内容的提问来源于stack exchange,提问作者Shrey Misra

