Reputation: 484
I'm trying to test out my android application which uses MQTT to receive messages. I receive the message as JSON which also contains a base64 encoded image. this works perfectly fine when the image is a few kilobytes , but when I try to send anything around 400KB the messages doesn't get sent.
I've used two public brokers both times got the same response. (test.mosquitto.org & iot.eclipse.org)
here's the JSON object being sent:
public void send() {
JSONObject obj = new JSONObject();
try {
obj.put("isFormat", Boolean.valueOf(true));
obj.put("title", "this is a title");
obj.put("image", "(insert base64 encoded image here)");
obj.put("imageExtension", "png");
obj.put("body", "<p>body</p>");
} catch (JSONException e) {
}
here's the code used to publish , using Paho android service client:
client.publish(topic,obj.toString().getBytes(),Constants.QoS_ACK,false,null,null);
Upvotes: 0
Views: 776
Reputation: 1
I think MQTT might not be comfortable with you sending the image within the JSON and you also doing a toString() which I doubt will help to encode back the image. try sending the image seperately and then bundle it with the json at reception. This should work!
Upvotes: 0