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

Messages are duplicated if wildcard and non-wildcard path exists

Open
#773 0 comments 0 reactions 0 assignees View on GitHub
triage
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.3 ( Master Branch)
- [ x ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.4-SNAPSHOT (Develop Branch)
- [ x ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.3-SNAPSHOT (Develop Branch)

Consider these two topics are registered via Paho on a broker:

```
- hello/1/world (paho listener A)
- hello/+/world (paho listener B)
```

Broker receives messages for topic

`hello/1/world`

Broker sends

`- 1 message to 2 subscriptions`

```
paho-client+hello/1/world (Subscriber A)
paho-client+hello/+/world (Subscriber B)
```

with topic

`hello/1/world`

Now what I consider as a bug:

Paho receives two messages, but instead of detecting that the subscriptions are equal delivers **4** messages:

> 1. hello/1/world for Subscriber A to listener A
> 2. hello/1/world for Subscriber A to listener B
> 3. hello/1/world for Subscriber B to listener A
> 4. hello/1/world for Subscriber B to listener B

This is because of
https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/CommsCallback.java#L502
where the subscribers are iterated, even though the broker (EMQX in this case) already knows that there are multiple subscriptions on the same client (Paho could avoid this by not subscribing two times in first place)

Log:
[paho.log](https://github.com/eclipse/paho.mqtt.java/files/4592560/paho.log)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.