I recognize a wierd bahavior with MQTT in B4R.
I set up and connect to my Mosquito Broker via:
If the ESP boot it sends "Offline" AND "Online" to the "statusTopic".
After the a disconnect of the ESP no LastWill will be sent.
It seems that the LastWill command does exactly the same as publish.
Where is my Problem?
In B4J the LastWill works as expected.
My B4J Server Application listen to every topic (#).
Im also using the latest B4R with rMQTT 1.30
I set up and connect to my Mosquito Broker via:
B4X:
Private Sub ConnectToNetwork
Wifi.Disconnect
Log("Trying to connect")
If Wifi.Connect2("Kindergarten", "XXXX") Then
Log("Connected successfully to: ", "Kindergarten")
Log("Local IP: ", Wifi.LocalIp)
mqtt.Initialize2(mqttSocket.Stream,"placeholder", "1883", UUID, "mqtt_MessageArrived", "mqtt_Disconnected") 'ignore
mo.Initialize("user", "password") 'ignore
mo.SetLastWill(statusTopic, "offline", 1, True)
If mqtt.Connect2(mo) Then
Log("MQTT connected")
mqtt.Subscribe(commandTopic,1)
mqtt.Publish2(statusTopic,"online".GetBytes,True)
End If
End If
End Sub
If the ESP boot it sends "Offline" AND "Online" to the "statusTopic".
After the a disconnect of the ESP no LastWill will be sent.
It seems that the LastWill command does exactly the same as publish.
Where is my Problem?
In B4J the LastWill works as expected.
My B4J Server Application listen to every topic (#).
Im also using the latest B4R with rMQTT 1.30
Last edited: