1
votes

https://github.com/fusesource/mqtt-client

i have an android application starting a background service where i have initiated an mqtt connection towards an apollo broker. when startService is called im initiating the MQTT from the onStartCommand setting hostname, port username, password etc.. followed by

connection = mqtt.callbackConnection();

the connect is successfull and i can clearly see that i have a consumer on my topic "uniqueId".

But when i send messages to my topic , the listener never calles the onPublish.. Another strange occurence is that if i loose my connection towards the broker , e.g i shut down the broker so that the active connection is broken, when the mqtt-client reconnects, it seems that it calles the listener and also the onPublish because then all the messages that i have stacked on my durable subscriber topic is delivered.. am i missing anything here regarding the listener?

isnt it suppose to actively consume the topic due to connection.subscribe??

Topic[] topics = { new Topic("uniqueId", QoS.AT_LEAST_ONCE) };
connection.subscribe(topics, new Callback<byte[]>() {
    public void onSuccess(byte[] qoses) {
    }
    public void onFailure(Throwable value) {
        value.printStackTrace();
    }
});

connection.listener(new Listener() {
    @Override
    public void onConnected() {
    }
    @Override
    public void onDisconnected() {
    }
    @Override
    public void onFailure(Throwable value) {
    }
    @Override
    public void onPublish(UTF8Buffer topic, Buffer payload, Runnable ack) {
        ack.run();
    }
});
1
seems to be working on both activemq and mosquitto.. anyone experienced this problem with apollo specifically?dunn less

1 Answers

1
votes

I'm not familiar with Apollo, but I agree that the behaviour sounds incorrect. You could try testing against another broker to see if it works as expected, then file a bug against Apollo if necessary.

You could use e.g. test.mosquitto.org:1883 to test against, or use one of the other public ones listed on mqtt.org/software