Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Android - waitForCompletion() when connecting

Hi Michael,
 
As far as I've found in my own use of the Library, using the IMqttActionListener is the best way to be notified of the connection being successful. From the looks of MqttTokenAndroid.java there is a synchronized lock on waitobject. This could be what's causing the deadlock in your application: https://github.com/eclipse/paho.mqtt.java/blob/develop/org.eclipse.paho.android.service/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttTokenAndroid.java#L80
 
The Android service is in need of a bit of a revamp so we're open to any suggestions on how to make it more user friendly / efficient / stable.
Kind regards,
 
James Sutton
Software Engineer - IoT Foundation - MQTT Open Source Projects
Technical Trojan - Wimbledon Project

Phone: 01962 815438 | Extension: x372454
E-mail: james.sutton@xxxxxxxxxx
Personal Website: www.jsutton.co.uk
Find me on:      
IBM

Hursley Park
HursleySO212JN
United Kingdom
 
IBM United Kingdom Limited Registered in England and Wales with number 741598 Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU
 
 
----- Original message -----
From: "onkelsers ." <dummyforforum@xxxxxxxxxxxxxx>
Sent by: paho-dev-bounces@xxxxxxxxxxx
To: General development discussions for paho project <paho-dev@xxxxxxxxxxx>
Cc:
Subject: Re: [paho-dev] Android - waitForCompletion() when connecting
Date: Mon, Jan 18, 2016 12:59 PM
 
Hi Ian,
 
I didn't find working code that uses just the MqttAndroidClient. A subscribe will fail if it's done too early, so I need to determine the point the connection is established.
The IMqttActionListener helped me here and I it is used as an example in the sample code you mentioned ( http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.paho.android.service.MqttAndroidClient ) .
I'm not sure if it's a good practice to put all subscriptions into the onSuccess block of the listener, but I don't know of another way the the moment.
 
Michael
 
 
 
2016-01-13 17:21 GMT+01:00 Ian Craggs <icraggs@xxxxxxxxxxxxxxxxxxxxxxx>:
Hi Michael,

James, who knows most about this, is away this week - I'll talk to him when he gets back.

Have you looked at any of the sample code to see if it shows you how it should work?  Seems like a natural use case.  Does subscribe fail if you call it too soon?  I was thinking it might get queued.

Ian
 
On 01/12/2016 09:56 AM, onkelsers . wrote:
Hello,
 
I'm using the Android service v 1.0.2. Calling the waitForCompletion method seems to create a deadlock, at least on my devices. I  tried it with an empty activity, creating only a client calling connect() and waitForCompletion() in onCreate().
 
Am I missing something here? I just want to determine the time the connection is established so I can subscribe to some fixed subjects.
 
Regards,
 
Michael
 
 
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
--
Ian Craggs                          
icraggs@xxxxxxxxxx                 IBM United Kingdom
Paho Project Lead; Committer on Mosquitto

 

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
 
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Back to the top