eclipse/paho.mqtt.c

Duplicate QoS 0 messages received

nirmitdesai opened this issue · 2 comments

Describe the bug
Duplicate QoS 0 messages received

Log files

=========================================================
                   Trace Output
Product name: Eclipse Paho Asynchronous MQTT C Client Library
Version: 1.3.12
Build level: 2024-02-09T20:34:57Z
OpenSSL version: OpenSSL 3.0.12 24 Oct 2023
OpenSSL flags: compiler: cl  /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 -DL_ENDIAN -DOPENSSL_PIC
OpenSSL build timestamp: built on: Thu Nov  2 05:53:18 2023 UTC
OpenSSL platform: platform: VC-WIN64A
OpenSSL directory: OPENSSLDIR: "C:\Program Files\SSL"
=========================================================
20240429 051700.540 Connecting to serverURI <SERVERURI>:31883 with MQTT version 5
20240429 051700.772 SSL cipher available: 0:TLS_AES_256_GCM_SHA384
...
20240429 051700.845 SSL connect:SSL negotiation finished successfully
20240429 051700.846 2184 my-client-id -> CONNECT version 5 clean: 0 (0)
20240429 051700.848 2184 my-client-id <- CONNACK rc: 0
20240429 051700.849 2184 my-client-id -> SUBSCRIBE msgid: 1 (0)
20240429 051700.852 2184 my-client-id <- SUBACK msgid: 1
20240429 051700.852 2184 my-client-id -> PUBLISH msgid: 2 qos: 2 retained: 0 rc 0 payload len(157): {"agentIdentity":"ag
20240429 051700.853 2184 my-client-id -> PUBLISH qos: 0 retained: 1 rc: 0 payload len(142): {"host":"my-client-
20240429 051700.854 2184 my-client-id <- PUBREC msgid: 2
20240429 051700.854 2184 my-client-id -> PUBREL msgid: 2 (0)
20240429 051700.857 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(362): {"agentAnnounceTopic
20240429 051700.897 2184 my-client-id -> SUBSCRIBE msgid: 3 (0)
20240429 051700.898 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(362): {"agentAnnounceTopic
20240429 051700.937 2184 my-client-id -> SUBSCRIBE msgid: 4 (0)
20240429 051700.938 2184 my-client-id -> SUBSCRIBE msgid: 5 (0)
20240429 051700.938 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(362): {"agentAnnounceTopic
20240429 051700.977 2184 my-client-id -> SUBSCRIBE msgid: 6 (0)
20240429 051700.977 2184 my-client-id -> SUBSCRIBE msgid: 7 (0)
20240429 051700.978 2184 my-client-id -> SUBSCRIBE msgid: 8 (0)
20240429 051700.978 2184 my-client-id <- PUBCOMP msgid:2
20240429 051700.979 2184 my-client-id -> SUBSCRIBE msgid: 9 (0)
20240429 051700.980 2184 my-client-id -> SUBSCRIBE msgid: 10 (0)
20240429 051700.980 2184 my-client-id -> SUBSCRIBE msgid: 11 (0)
20240429 051700.982 2184 my-client-id <- SUBACK msgid: 3
20240429 051700.983 2184 my-client-id -> PUBLISH msgid: 12 qos: 2 retained: 0 rc 0 payload len(93): {"subscribeTopic":"d
20240429 051700.984 2184 my-client-id -> PUBLISH qos: 0 retained: 1 rc: 0 payload len(143): {"host":"my-client-
20240429 051700.985 2184 my-client-id <- SUBACK msgid: 4
20240429 051700.985 2184 my-client-id <- SUBACK msgid: 5
20240429 051700.987 2184 my-client-id <- SUBACK msgid: 6
20240429 051700.987 2184 my-client-id -> PUBLISH msgid: 13 qos: 2 retained: 0 rc 0 payload len(93): {"subscribeTopic":"d
20240429 051700.988 2184 my-client-id -> PUBLISH qos: 0 retained: 1 rc: 0 payload len(143): {"host":"my-client-
20240429 051700.989 2184 my-client-id <- SUBACK msgid: 7
20240429 051700.989 2184 my-client-id <- SUBACK msgid: 8
20240429 051700.990 2184 my-client-id <- SUBACK msgid: 9
20240429 051700.991 2184 my-client-id -> PUBLISH msgid: 14 qos: 2 retained: 0 rc 0 payload len(93): {"subscribeTopic":"d
20240429 051700.992 2184 my-client-id -> PUBLISH qos: 0 retained: 1 rc: 0 payload len(143): {"host":"my-client-
20240429 051700.992 2184 my-client-id <- SUBACK msgid: 10
20240429 051700.993 2184 my-client-id <- SUBACK msgid: 11
20240429 051700.993 2184 my-client-id <- PUBREC msgid: 12
20240429 051700.994 2184 my-client-id -> PUBREL msgid: 12 (0)
20240429 051700.994 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051700.997 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.000 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.004 2184 my-client-id <- PUBREC msgid: 13
20240429 051701.004 2184 my-client-id -> PUBREL msgid: 13 (0)
20240429 051701.004 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.007 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.011 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.014 2184 my-client-id <- PUBREC msgid: 14
20240429 051701.014 2184 my-client-id -> PUBREL msgid: 14 (0)
20240429 051701.015 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.018 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.021 2184 my-client-id <- PUBLISH msgid: 0 qos: 0 retained: 0 payload len(129): {"dataTopic":"deskto
20240429 051701.025 2184 my-client-id <- PUBCOMP msgid:12
20240429 051701.025 2184 my-client-id <- PUBCOMP msgid:13
20240429 051701.026 2184 my-client-id <- PUBCOMP msgid:14
20240429 051704.466 2184 my-client-id -> PUBLISH qos: 0 retained: 1 rc: 0 payload len(0): 
20240429 051704.467 2184 my-client-id -> DISCONNECT (0)
20240429 051704.467 SSL alert write:warning:close notify

Expected behavior
Expected to receive the message only once

** Environment (please complete the following information):**

  • OS: Windows Server 2022

Additional context

The client has subscribed to the topic with QoS 2. However, you can see that after MQTT connection was successful, it received same message with payload agentAnnounceTopic thrice with QoS 0.
In response, my client sent a payload thrice (with content subscribeTopic ).
And in response to that, I received a payload 9 times! How can this happen?
Would appreciate some insights, thanks!

You've subscribed to several topics. Depending on the MQTT broker, if these subscriptions are different but overlap, for instance, a, + and #, you might receive one message back when you publish to "a" or 3. Both are allowed.

It depends what you've subscribed to, what you've published to, and the broker.

The question has been answered.