Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Detecting timeout between device and server
Detecting timeout between device and server [message #1721525] Thu, 28 January 2016 00:08 Go to next message
Edward Woodhouse is currently offline Edward WoodhouseFriend
Messages: 12
Registered: September 2015
Junior Member
Is there a way to detect when the connection between client and server has timed out?

I understand that the library makes no attempt to automatically reconnect, however calling client.reconnect() inside connectionLost() does not seem to be enough to guarentee that connection is restablished in all scenarios.

There are scenarios where either connectionLost is not called or client.reconnect has no effect (its hard to debug because I have to be moving about a lot during the day to detect these issues).

Regaining connection in all scenarios is core functionality for my application, if anyone has any ideas or suggestions, I would appreciate it. Thanks!
Re: Detecting timeout between device and server [message #1721565 is a reply to message #1721525] Thu, 28 January 2016 10:48 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
Hi Edward,
connectionLost() *should* catch any situation in which the connection is lost, I'm guessing this is the Java client? If there are any scenarios where it's not being called that would be good to get some debug information about. You could try turning on Trace in your application which may help us figure out what's going on under the covers: https://wiki.eclipse.org/Paho/Log_and_Debug_in_the_Java_client
Re: Detecting timeout between device and server [message #1721844 is a reply to message #1721565] Mon, 01 February 2016 02:16 Go to previous messageGo to next message
Edward Woodhouse is currently offline Edward WoodhouseFriend
Messages: 12
Registered: September 2015
Junior Member
Hey James, I'm using the Android service, is this the same thing?
Re: Detecting timeout between device and server [message #1723130 is a reply to message #1721844] Thu, 11 February 2016 22:54 Go to previous messageGo to next message
Edward Woodhouse is currently offline Edward WoodhouseFriend
Messages: 12
Registered: September 2015
Junior Member
Setting keepalive to 0 seems to fix the problem. I don't know what conclusions can be drawn from this discovery.
Re: Detecting timeout between device and server [message #1724189 is a reply to message #1723130] Mon, 22 February 2016 09:21 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
Hi Edward,

The Android service is a wrapper around the Java client which has some extra functionality that allows the app to reconnect if there was a change in network connection (E.g. Phone signal was lost then found). It also has some modified ping functionality that is better suited to android so that it does not drain the battery. I'm currently adding in full automatic reconnect & offline buffering into the core Java library this month which will mean that upon connection loss, the client will continually attempt to re-acquire the connection.

Setting Keepalive to 0 simply turns off the keep alive functionality. This can be good or bad depending on how you look at it: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/csprd02/mqtt-v3.1.1-csprd02.html#_Toc385349238
Effectively if the connection is lost, neither client or server will know until they attempt to send a message. This means that if your client was subscribed to one or more topics and the connection was lost, it would not receive any messages until it attempted to publish at which point it would discover the connection to be lost, would throw an error and would close the socket.
Re: Detecting timeout between device and server [message #1724284 is a reply to message #1724189] Mon, 22 February 2016 19:14 Go to previous message
Edward Woodhouse is currently offline Edward WoodhouseFriend
Messages: 12
Registered: September 2015
Junior Member
Thanks James, looking forward to it!
Previous Topic:Android App crashes when inactive due to wrong function call in AlarmPingSender
Next Topic:Paho java client - cannot create more than 5000 connections
Goto Forum:
  


Current Time: Fri Apr 26 05:26:36 GMT 2024

Powered by FUDForum. Page generated in 0.04086 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top