Search code examples
mqttmosquittopaho

MQTT subscribing to 100k retain messages


We have more than 100k retained messages for this topic 'devices/access_control/inout_status/by_project/#'. After subscribing, we are receiving around 8k-10k messages and then it disconnects with error 'Broken pipe' and after reconnecting, we are receiving the same 10k messages again. How can I solve this problem?


Solution

  • The message delivery is working as intended, you will always get the last retained message for a given topic when you subscribe to that topic.

    You are subscribing to a wildcard topic, if you have +10k subtopics under that branch of the topic tree then these messages will always be delivered when you reconnect.

    As to why it's dropping the connection with a Broken pipe error, this is probably because you can't process that many messages quickly enough and are flooding the receiver to the point where it can't even drive the low level TCP stack.