Each MQTT connection requires a unique client identifier. Thanks to this unique client identifier, the broker can find out when the client will reconnect and can close the old potentially half-open TCP connection for the client. In addition, the MQTT broker can conduct a permanent session for MQTT clients if they wish (cleanSession = false in CONNECT). If you disconnect and reconnect to the same customer ID, you will receive all messages for your subscribers that you may have missed, and the broker knows your old subscriptions for this customer ID.
source share