Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] MqttService not reconnecting

I would like to share my experience about using Paho Android service 1.0.2.

Neither my Android app nor Paho Android sample can reconnect to MQTT broker after closing the main activity. It means the app never receives the push notification after closing the main activity. It's something really confused behavior. The official site states "The Paho Android Service is an interface to the Paho Java MQTT client library that provides a long running service for handling sending and receiving messages on behalf of Android client applications when the applications main Activity may not be running."

Looks like the Paho android service just is a library in Android, it can not remember the broker information and reconnect to the broker after the service is restarted by Android OS(Android OS might kill the service then relaunch it later for releasing resource). I have to implement myself android service which consumes Paho Android service to reconnect to the broker then subscribe the topics if necessary.

Paho Android service only can reconnect to the broker without cleaning session and the network becomes available from unavailable state. But it can not reconnect to broker if something wrong(such as server side error response) happens causing the connect lost. Anyway I can monitor the MQTT connection lost event in my Android service, and reconnect to the broker.


Kane

On Tue, May 5, 2015 at 3:48 PM, Manuel Domínguez Dorado <manolodd@xxxxxxxxx> wrote:
Mmmm, I'll try this evening. I did not try this combination :-) However as onDestroy() is not called always I do not know how to determine the behaviour of the app.What I've supposed is:

- The resources are registered once the client is connected, automatically (isn't it?).
- You have to register resources in onRestart() (From the javadoc: "Call this method when activity is hidden and become to show again").
- Is it necessary to perform an explicit call to registerResources()??

However I cannot see it clearly neither in eclipse sample nor in IBM ones ("pickme-up" app). I'll continue trying.

Thank you.


2015-05-04 23:42 GMT+02:00 ravi lakhotia <ravilakhotia2006@xxxxxxxxx>:
Hi Manuel,

I resolved this by registering resources in onResume() of the Activity and by unregistering resources in onDestroy. It seems to work fine, I haven't done thorough check though.

thanks,

On Tue, May 5, 2015 at 2:39 AM, Manuel Domínguez Dorado <manolodd@xxxxxxxxx> wrote:

Hi,

I've been trying myself. Everything ok untill I let the activity to rotate from portrait to landscape and viceversa. From this point everything is very confushing, lots of leak problems, some exceptions not only in the same point/circumstance... I think that the reason is that I missed some unregisterResources() call. Is there some insrtructions on how to use registerResources() and unregisterResources() in an orientation-free app?

Regards.

El 04/05/2015 16:22, "ravi lakhotia" <ravilakhotia2006@xxxxxxxxx> escribió:
Hi Ian,

Every time network is disconnected, connectionLost is called. When connection is back I can see through tracedebug that reconnect happens. But my client is not able to publish anything once the Network is back.

What do I need to for my existing client to publish once the connection is back ?

thanks,

On Fri, Apr 10, 2015 at 9:34 PM, Ian Craggs <icraggs@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi Ravi,

has this ever worked for you before?

How are you expecting the reconnect to work?  Have you implemented the connectionLost callback?

Ian


On 04/10/2015 07:08 AM, ravi lakhotia wrote:
Hi All,

MqttService was not reconnecting when connection was lost and came back, also when activity was restarted with version 1.0.1 jars.

I have imported 1.0.2 service and java client jars and issue is still there.

are there any API changes which we need to make to get these issues gone?
Could someone please help me on this one?

thanks in advance !

--
Ravi Lakhotia



_______________________________________________
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



--
Ravi Lakhotia
Co-Founder, Green Home Electronics
+91 9916399916

_______________________________________________
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



--
Ravi Lakhotia
Co-Founder, Green Home Electronics
+91 9916399916



--
---
Manuel Domínguez Dorado
ingeniero ARROBA ManoloDominguez PUNTO com
http://www.ManoloDominguez.com

_______________________________________________
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


Back to the top