MQTT V5 协议文档 中有提到,只有在客户端断线重连的情况下,服务器和客户端才能重发 PUBLISH 和 PUBREL,如下:
When a Client reconnects with Clean Start set to 0 and a session is present, both the Client and Server MUST resend any unacknowledged PUBLISH packets (where QoS > 0) and PUBREL packets using their original Packet Identifiers. This is the only circumstance where a Client or Server is REQUIRED to resend messages. Clients and Servers MUST NOT resend messages at any other time [MQTT-4.4.0-1].
这是否意味着,例如服务器如果想要重发 QoS 1 消息,不能直接发送 DUP = 1 的 PUBLISH 数据包,而是只能断开网络连接?随后还必须等待客户端发送 CONNECT,重连后才能重发消息?
查询了 github 上相关的讨论,发现了这个回答,表示 EMQX 有ACK超时机制,可以重传ACK超时的包。
已打开 08:01AM - 11 Jun 21 UTC
已关闭 01:51AM - 07 Jul 21 UTC
help wanted
#### Describe the problem you Confuse
Hi, my java application use hive-mqtt-… client-1.2.2(mqttV5 protocol) to sub emqx-4.2.2, my iot equipment use mqttV3.1 to pub to emqx, that means I use different mqtt protocols in clients to communicate with emqx, is it OK?
sometimes there is error message in log:
`2021-06-09 19:29:30.806 [com.hivemq.client.mqtt-10-2] ERROR c.h.c.i.m.h.p.incoming.MqttIncomingQosHandler:51 - QoS 1 PUBLISH (MqttStatefulPublish{stateless=MqttPublish{topic=BGT1/1918BD000186/PeriodReportBin, payload=65byte, qos=AT_LEAST_ONCE, retain=false}, packetIdentifier=419, dup=false, topicAlias=0, subscriptionIdentifiers=[9]}) must not be resent (MqttStatefulPublish{stateless=MqttPublish{topic=BGT1/1918BD000186/PeriodReportBin, payload=65byte, qos=AT_LEAST_ONCE, retain=false}, packetIdentifier=419, dup=true, topicAlias=0, subscriptionIdentifiers=[9]}) during the same connection`
I also asked this question at `https://github.com/hivemq/hivemq-mqtt-client/issues/491`, @LBrandl said that `https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901236` `4.4 Message delivery retry`:
`When a Client reconnects with Clean Start set to 0 and a session is present, both the Client and Server MUST resend any unacknowledged PUBLISH packets (where QoS > 0) and PUBREL packets using their original Packet Identifiers. This is the only circumstance where a Client or Server is REQUIRED to resend messages. Clients and Servers MUST NOT resend messages at any other time [MQTT-4.4.0-1].`
this means emqx should not resend this message to subscriber? is it caused by different mqtt protocols used by publisher and subscriber?
#### More detail (optional)
![image](https://user-images.githubusercontent.com/5837440/121652448-3ec36a80-cace-11eb-944f-95631673ad62.png)
请问是否是这个情况呢?这样的设计是否属于违背了规范呢?还有,既然规范要求不能在非重连的情况下重传,那怎么重传 QoS 1 的包才算合理呢?