Android Question MQTT payload type

Discussion in 'Android Questions' started by August Jimenez, Oct 18, 2018.

  1. August Jimenez

    August Jimenez Member Licensed User


    I'm doing some test with a MQTT broker, using the MQTTBox tool, to verify all is working well, before use my APP. The topic to publish and the payload used are in the following screenshot:


    With this tool, all is working fine. When I use the APP, I can connect to the broker perfectly, but the publish topic does not arrive correctly. My piece of code is the following:

    Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    "mqtt", serverURI, "xxxxxxx")

    Dim mo As MqttConnectOptions

    Dim jo As JavaObject = mo


    End If
    End Sub

    Sub CreateTrustAllSSLSocketFactory As Object
    Dim tm As CustomTrustManager
    Dim SSLContext As JavaObject
        SSLContext = SSLContext.InitializeStatic(
    "init"Array(Null, tm, Null))
    Dim Factory As JavaObject = SSLContext.RunMethod("getSocketFactory"Null)
    Return Factory
    End Sub

    Sub mqtt_Connected (Success As Boolean)
    If Success = False Then 
    Log("Error connecting: " & LastException)

    "v/a/g/141414141414/s/temperature-141414141414-1", serializator.ConvertObjectToBytes("1539878280000,25.5"))

    End If
    End Sub
    As can be seen in the screenshot, the payload should be "Strings / JSON / XML / Characters", but in the "Publish" method of the jMQTT library, the payload must be "Byte".

    How can I send this kind of payload?

    Thanks and regards

    Attached Files:

  2. DonManfred

    DonManfred Expert Licensed User

    Johan Hormaza likes this.
  3. August Jimenez

    August Jimenez Member Licensed User

    Thank you very much, DonManfred. Now it's working well.

    DonManfred likes this.
  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