eclipse-paho / eclipse-paho/paho.mqtt.java

calling setActionCallback on token returned by MqtttAsyncClient.connect is ineffective

Open
#939 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

Please fill out the form below before submitting, thank you!

- [ X ] Bug exists Release Version 1.2.5 ( Master Branch)
- [ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)

**sample pom.xml**
```sh

org.eclipse.paho
org.eclipse.paho.mqttv5.client
1.2.5

```

**sample code**
```java
token = mqttClient.connect(getOptions()
MemoryPersistence persistence = new MemoryPersistence();
mqttClient = new MqttAsyncClient(broker, clientId, persistence);
IMqttToken token = mqttClient.connect(getOptions(), null, null);
token.setActionCallback(listener)
```
**expected result:** is listener.onSuccess is called when connection is complete

**actual result :** no call is perrormed.

_note using :_
```java
IMqttToken token = mqttClient.connect(getOptions(), null, listener);
```
will result in listener.onSuccess being called.

**see also :** code comment from IMqttToken :

```java
/**
* Register a listener to be notified when an action completes.
*

Once a listener is registered it will be invoked when the action the token
* is associated with either succeeds or fails.
*


* @param listener to be invoked once the action completes
*/
public void setActionCallback(MqttActionListener listener);
```

Contributor guide

Open the contributing guide

Research direction

Start with MqttAsyncClient.connect and the IMqttToken.setActionCallback contract, then reproduce the sample using MqttAsyncClient.connect(getOptions(), null, null). Compare it with passing the listener directly to connect; done means the token callback is invoked on successful completion as the interface documentation describes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.