Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Listening to token from connect call
Listening to token from connect call [message #1692216] Tue, 14 April 2015 11:24 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 662
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm using the async Paho Java client. I call connect() and register a
listener on the returned token, but I never receive either success or
failure notifications. However, the connection works, e.g. sending messages.

Isn't the token returned by connect() intended to be used this way?

Hallvard
Re: Listening to token from connect call [message #1692239 is a reply to message #1692216] Tue, 14 April 2015 13:30 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 60
Registered: March 2013
Member
Hi Hallvard,

I think this should work. Do you get success/failure callbacks for any other operations like publish or subscribe?

Ian
Re: Listening to token from connect call [message #1693449 is a reply to message #1692239] Fri, 24 April 2015 10:15 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 662
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 14.04.15 15:30, Ian Craggs wrote:
> Hi Hallvard,
>
> I think this should work. Do you get success/failure callbacks for any
> other operations like publish or subscribe?

Sort of... For the connection I get nothing, while for the publish I get
notified of success when the application shuts down. I see the publish
goes through immediately (using the Paho RCP application), but the
listener seems to be notified only when the connection is closed.

Here's the code for the two cases:
token.setActionCallback(new IMqttActionListener() {
@Override
public void onSuccess(IMqttToken arg0) {
System.out.println("Success!");
System.out.flush();
}
@Override
public void onFailure(IMqttToken arg0, Throwable arg1) {
System.out.println("Failed!");
System.out.flush();
}
});

BTW, I use the paho Mqtt bundle shipping with the Paho RCP application,
not the standalone library.

Hallvard
Re: Listening to token from connect call [message #1697804 is a reply to message #1693449] Mon, 08 June 2015 14:37 Go to previous message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 60
Registered: March 2013
Member
Hmm. I don't see how this would work reliably. There must be a timing window between getting the token returned from the call, and setting a listener on it. If the call completes very quickly, you wouldn't get notified. I'll check with the author.
Previous Topic:Paho C++ connect options problem
Next Topic:Java client: Trouble connecting to CloudMQTT server with username password
Goto Forum:
  


Current Time: Tue Sep 25 23:39:14 GMT 2018

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

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

Back to the top