Aias00 opened a new issue, #7919:
URL: https://github.com/apache/shenyu/issues/7919

   ### Behavior and reproduction
   
   At `fda742c48e7f553c9964cf74b36732326d0fde00`, an inbound QoS 2 
retransmission is forwarded as a new publication instead of being recognized as 
the same in-flight message.
   
   Executed using the real Publish handler, SubscribeRepository, a connected 
publisher and a Netty EmbeddedChannel subscriber:
   
   1. Subscribe at QoS 2 to qos2/probe.
   2. Send a PUBLISH with QoS 2, packetId 77, DUP false and payload payload.
   3. Wait for the first forwarded PUBLISH.
   4. Before any PUBREL, resend the same PUBLISH with packetId 77 and DUP true, 
as a client does when recovering the QoS 2 handshake.
   5. Observe a second forwarded PUBLISH. The subscriber-side packet IDs are 
**1 and 2**, so this is not one downstream QoS 2 retransmission that a 
subscriber can deduplicate.
   
   The probe used latches for asynchronous send completion, not sleeps, and 
released inbound/outbound message buffers. The server's correct PUBREC packet 
type does not prevent duplicate application delivery.
   
   ### Location and cause
   
   - [Every incoming PUBLISH schedules send before checking handshake 
state](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java#L73)
   - [QoS 2 branch sends PUBREC but stores no in-flight receive 
state](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java#L112)
   - [Each send assigns a fresh subscriber packet 
ID](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Publish.java#L130)
   - [PUBREL only sends 
PUBCOMP](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/PubRel.java#L38)
   
   No per-session receive-side QoS 2 state suppresses duplicate packet IDs 
between PUBLISH/PUBREC and PUBREL/PUBCOMP.
   
   ### Expected behavior / suggested repair
   
   Track receive-side QoS 2 exchanges per client/session, acknowledge 
retransmitted PUBLISH without delivering it again, and complete/release state 
at the appropriate PUBREL/PUBCOMP boundary. Define persistent-session/reconnect 
handling and cleanup. Test retransmission both before and after handshake 
steps, and assert exactly one downstream application publication.
   
   Medium severity, high confidence. Distinct from closed #6743, which 
corrected PUBACK to PUBREC; the current code already sends PUBREC, while the 
handshake deduplication/state machine is still absent. 
Wildcard/SUBACK/retained-message issues do not cover this path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to