From my reading I see that setting MqttConnectOptions.cleansession = false should allow messages sent while the client was closed to be received. In testing I haven't gotten this to work. Everything else works fine for sending and receiving messages.
B4X:
Sub Process_Globals
Private mqtt As MqttClient
Private mytopic As String
Private serializator As B4XSerializator
Dim mo As MqttConnectOptions
....
End sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
mqtt.Initialize("mqtt", "...mybroker address", "...my clientID")
mo.Initialize("username", "password")
mo.CleanSession = False
mqtt.Connect2(mo)
mytopic = "TestTopic/"
...
end sub
I had already read and re-read all the mqtt essentials chapters. Chapter 7 doesn't make it terribly clear but I'm guessing now that a persistent session is created if the ClientID remains the same between closing and reconnecting. I'm also assuming that it means that each subscriber needs to have a different clientID (makes sense). If that's not it then I'm still missing the point. They could have made that clearer.
Nice to hear, that its not terribly clear - in this situtation i always think its my problem because my english is not good enough...
I think, your assumptions are right.
Nice to hear, that its not terribly clear - in this situtation i always think its my problem because my english is not good enough...
I think, your assumptions are right.