Search code examples
pythonnetwork-programmingmqttmosquitto

mosquitto mqtt broker won't send more than 20 publish packets to subscriber


I'm currently working on a MQTT client using python, and come to the point where i can create clients that publish and subscribe to the Mosquitto broker.

The problem is that, no matter what, the mosquitto broker will send only a maximum of 20 PUBLISH packets to a subscriber client, even if it stay connected for long periods of time.

How can I configure mosquitto to send more than 20 PUBLISH packets to the subscriber client?

Mosquitto log:

1608918436: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918436: Sending PUBLISH to subscriber (d0, q1, r0, m17, '/OS', ... (3 bytes))
1608918436: Sending PUBACK to publisher (m1, rc0)
1608918438: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918438: Sending PUBLISH to subscriber (d0, q1, r0, m18, '/OS', ... (3 bytes))
1608918438: Sending PUBACK to publisher (m1, rc0)
1608918440: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918440: Sending PUBLISH to subscriber (d0, q1, r0, m19, '/OS', ... (3 bytes))
1608918440: Sending PUBACK to publisher (m1, rc0)
1608918442: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918442: Sending PUBLISH to subscriber (d0, q1, r0, m20, '/OS', ... (3 bytes))

at this point, the mosquitto broker won't send more packets to the subscriber, excepting PINGRESP when the subscriber client sends PINGREQ in order to remain connected to the broker.

1608918442: Sending PUBACK to publisher (m1, rc0)
1608918442: Received PINGREQ from subscriber
1608918442: Sending PINGRESP to subscriber
1608918444: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918444: Sending PUBACK to publisher (m1, rc0)
1608918446: Received PUBLISH from publisher (d1, q1, r0, m1, '/OS', ... (3 bytes))
1608918446: Sending PUBACK to publisher (m1, rc0)

I'll be happy to provide the code for the client if it's actually needed.

Later edit: Maybe it's worth mentioning
If there are more subscribers on one topic, this behavior is not observable, the broker sends packets without stopping at any point whatsoever.


Solution

  • 20 messages sounds like you are hitting the max number of inflight messages (max number of unacknowledged messages)

    The messages are QOS 1 so your client needs to acknowledge them.