Skip to main content



      Home
Home » Eclipse Projects » Paho » Listening to token from connect call
Listening to token from connect call [message #1692216] Tue, 14 April 2015 07:24 Go to next message
Eclipse UserFriend
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 09:30 Go to previous messageGo to next message
Eclipse UserFriend
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 06:15 Go to previous messageGo to next message
Eclipse UserFriend
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 10:37 Go to previous message
Eclipse UserFriend
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: Thu Jul 10 08:23:43 EDT 2025

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

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

Back to the top