apache / apache/shenyu

[BUG] Subscriber fan-out always QoS 0 and reuses publisher's packetId for every subscriber

Open
#6,850 2 comments 0 reactions 1 assignee Claimed by @wy471x View on GitHub
plugin: mqtt priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
`SubscribeRepository.add(Channel, List)` stores only `channel`, throwing away `s.qualityOfService()`. `Publish.send` hard-codes `MqttQoS.AT_MOST_ONCE` for fan-out and uses `new MqttPublishVariableHeader(topic, packetId)` reusing the inbound publisher's `packetId` for every downstream subscriber.

## Location
- `shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java:120-121`
- `shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/repositories/SubscribeRepository.java:56-62`

## Impact
QoS 1/2 subscribers receive at-most-once delivery (no redelivery, no ack correlation). Reusing the publisher's packet ID across distinct subscriber channels corrupts each subscriber's in-flight window/ack correlation. Violates MQTT-3.6.

## Suggested fix
Store per-subscriber QoS in `SubscribeRepository`; allocate a per-subscriber packetId from each subscriber channel's own id space; deliver at the granted QoS.

## Related existing
Distinct from MQTT-03 (#6743, broker→publisher PUBREC direction) and MQTT-04 (#6744, ByteBuf leak) — this is the broker→subscriber fan-out direction.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.