Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Paho API in Android Messaging

Tucker,

It may be that the client and/or broker isn't happy with the # wildcard as the subscription topic.  For example the mosquitto_sub client app doesn't accept that(didn't test to see if the broker does). Maybe try something like +/# or +/# AND + if you really want "everything"

-Darren


On Tue, Nov 26, 2013 at 2:43 AM, Rhys Short <rhys.short@xxxxxxxxxxx> wrote:
Hi Tucker,

What is the logcat output when you run your application? It might have some clues to why your app is not working as expected.

Regards

Rhys 

On 26 Nov 2013, at 03:07, "Tucker Vento" <tuckervento@xxxxxxxxx> wrote:

hi paho people

I'm working on a (hopefully) lightweight two person messaging app using the MQTT protocol, and currently I'm trying to use the paho library to accomplish this.  I have a mosquitto broker running on a debian box, and as far as I can tell it's running without issue.  however, I am unable to receive messages on my app; publishing them works fine, and I can watch with a command line client from the server and see the message arrive, but neither Android client will receive a message from the other.  I'm implementing MqttCallback on my service...this is also my first app, so it's possible I'm misunderstanding some part of the Android lifecycle, but I think the service should be open to receive connections from the broker?  Here's where I set up the client on the service:

public void setUpService(final Context p_context){
    setUpDatabases(p_context);
    try {
        _mqttClient = new MqttAsyncClient(_mqttServer, _clientId, new MqttDefaultFilePersistence(p_context.getFilesDir().getAbsolutePath()));

        _mqttClient.setCallback(this);
        _mqttOptions.setCleanSession(false);
        _mqttOptions.setKeepAliveInterval(_keepAlive);
        _mqttOptions.setConnectionTimeout(_connectionTimeout);
        IMqttToken token = _mqttClient.connect(_mqttOptions);
        token.waitForCompletion();
        IMqttToken token2 = _mqttClient.subscribe("#", 2);
        token2.waitForCompletion();
    } catch (MqttException e) {
        handleMqttException(e);
    }
    SETUP_STATE = true;
}

that's all the code directly related to setting up the connection...in debugging, I found that my messageArrived override is never even being called.  that seems like an awful small amount of code to set up such an integral part of my app...so I'm thinking it's too good to be true (hence it not working).  am I missing some part of the set-up process?  could my service be blocked somewhere else and therefore never receiving these messages?  it seems unlikely that they would NEVER come through...considering the app isn't locked up or anything.

I'm at an impasse, so any guidance would be very appreciated!

thanks,
tucker


--
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev



Back to the top