Android Question MQTT Payload encoding

archeus

Member
Licensed User
Longtime User
Following this post
https://www.b4x.com/android/forum/threads/b4x-mqtt-chat-room.61568/

I was testing the code provide by Erel with CloudMQTT.

No problem to make it work, change the code to use it just like a client.

But if I use let's say MqttFX (MQTT client in Java) or MyMQTT and connect it to my CloudMQTT account (I use another credential than the one use in my Android App).

Each time MqttFX send message, My Android App crash. And all message sent by my app are unreadeable by MyMQTT or MqttFX.
If I deploy my app on 2 different android device, they are perfectly able to communicate, no crash. MyMQTT and MqttFX are perfectly able to communicate each other.

Problem seems to be here (in Starter)

B4X:
Private Sub client_MessageArrived (Topic AsString, Payload() As Byte)Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)

I saw on some MQTT docs that Payload are Byte.

I try to log Payload to see the data but crash (i'm a B4a newbie btw).

Is this code use a different format than the one usually use by other software to send data ? How can I convert text coming from traditional mqtt software to be readable by the App ?

Thanks for help
 
Top