Hi Team,
I am trying to build a simple chat solution for mobile using HiveMQ community edition.
I am able to get it to work, but at times the client/app is not receiving messages from broker even if the subscription exists for a specific topic, however, able to receive messages from other topics. However, if I publish messages from the same client it is working. I am not able to pin point the root cause of the issue. Any help would be greatly appreciated.
As of now, I am using a flutter lib which is providing MQTT v3 implementation.
Also, at times I am able to see frequent connect/disconnect messages after which the above issue occurs.
Additionally, I am using persistent sessions with high session expiry and QOS is set to exactly once.
Thanks
Hi @abhinavkumar185
Greetings! We’re thrilled to have you here, showing interest in MQTT and the HiveMQ broker. Welcome to the HiveMQ Community! We’re always happy to see new users.
Thank you for reaching out and providing detailed information regarding your setup.
It sounds like you’re encountering an intermittent issue where the client does not receive messages from the broker on certain topics, despite having an active subscription. Since you’re using persistent sessions with high session expiry and QoS 2, it’s important to ensure the message flow and subscription details are correct.
To assist in investigating this issue, I would recommend utilizing the HiveMQ MQTT Message Log Extension, which is open-source and available for the HiveMQ Community Edition. This extension allows you to log all MQTT packets incoming and outgoing from clients, helping you trace subscription-related issues more effectively. You can capture detailed logs of the connect, disconnect, publish, and subscribe events to further analyze the problem.
Please feel free to give this a try and let us know if you need further assistance. We are happy to help you troubleshoot the issue based on the log findings.
Best regards,
Dasha from The HiveMQ Team
Thanks @Daria_H
I am already using it, but will have a go at it again.
Is there any specific reason(s) under which broker will not publish the data to clients ?
Also, if the client keeps the connection open and does not initiate a disconnect/un-subscribe, can there be issues in future subscription when the client attempts to connect again ?
Hello @abhinavkumar185 ,
There can be a few reasons why a broker may not publish data to subscribing clients. A common reason would be that the client is currently disconnected or not available on the network. Message delivery can also change depending on the QoS (Quality of Service) level attached to the subscription, and the published message.
For example, if a subscription to the topic test/topic
is made with a QoS of 0, and the client falls offline during a publish to this topic, this message will not be delivered.
If this same subscription is made with QoS 1, this message will be added to the client queue for delivery once the client is able to receive messages once more, up to the point that the client queue is full. Once the client queue is full, additional messages will be dropped.
When setting a subscription to QoS 2, this will also utilize the client queue, but also requires that the client fulfill QoS 2 requirements when receiving the message, which involves the return of a PUBCOMP
packet when delivery completes.
More details on these QoS differences can be found here.
If the client maintains an open connection (and responds with PINGREQ/PINGRESP) for a client session, the session will be maintained for as long as the client remains active. If the client disconnects, behavior for persistence will be different depending on if the client is using MQTT 3.1.1 or MQTT 5. Our blog here covers persistence for MQTT 3 clients, and here covers persistence for MQTT 5 clients.
Best,
Aaron from the HiveMQ Team