B4R Question MQTT LastWill

Discussion in 'B4R Questions' started by Blueforcer, Oct 25, 2018.

  1. Blueforcer

    Blueforcer Active Member Licensed User

    I recognize a wierd bahavior with MQTT in B4R.
    I set up and connect to my Mosquito Broker via:

    Private Sub ConnectToNetwork
    Log("Trying to connect")
    If Wifi.Connect2("Kindergarten""XXXX"Then
    Log("Connected successfully to: ""Kindergarten")
    Log("Local IP: ", Wifi.LocalIp)
    "placeholder""1883", UUID, "mqtt_MessageArrived""mqtt_Disconnected"'ignore
            mo.SetLastWill(statusTopic, "offline"1True)
    If mqtt.Connect2(mo) Then
    Log("MQTT connected")
    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: Oct 25, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    When the program starts to run it actually starts twice. As a test add Delay(5000) at the beginning of the program and see whether you still see this behavior.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice