B4J Question MQTT topic subscription expiring

Didier9

Well-Known Member
Licensed User
Longtime User
I have been experimenting with the MQTT library, helped by a Raspberry Pi running Mosquitto.

This is a general MQTT issue rather than a specific B4J library question but I would like confirmation from someone with more experience with the protocol.

It seems like any subscription to a particular topic expires when you disconnect from the server. This is actually great news, I thought the subscriptions were persistent (tied to your client ID), even though I have not found anything about it in the online documentation, one way or the other. That would have been an issue since there is no way to poll the server to find out what you are subscribed to.

That means you have to resubscribe each time you connect. In the scheme of things, it's much better than my original assumption.

TIA
 

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you, that was not obvious from reading the various sites about MQTT.

I have another question though...
I am not clear about when the server itself dumps a topic (and the data published to it). The server cannot store every topic created and the data associated with it forever or it would eventually run out of memory, so I would like to know when the server cleans house and dumps the data.

My setup currently has one server and two clients. One client is running on the same Raspberry Pi that runs the server and the other is the B4J client I am working on.
The R-Pi client does publish to test/topic but is not explicitly subscribed to it.

When I 1) start the server, then 2) start the R-Pi client, then 3) publish a piece of data to test/topic using the R-Pi client, then 4) start the B4J client and subscribe to test/topic, the B4J client gets the message that was posted in 3) even though when the message was posted, nobody was subscribed to the topic. I also observe that the R-Pi client disconnects from the server as soon as the data is posted such that between 3) and 4), nobody is connected to the server. Is the server holding the data "for a while" before cleaning house?

I am trying to understand the issues associated with potentially running a server for a long while with a number of clients with possibly a number of orphan topics. I am sure the designers of the protocol have come up with a way to deal with it but for that too, I have not found much information.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you, I remember now reading about this flag.
There is a lot of material to absorb...
 
Upvote 0
Top