共享订阅没有和mqtt协议标准一致

环境信息

  • EMQ X 版本:5.0.0
  • 操作系统及版本:
  • 其他

问题描述

  1. mqtt 标准协议,共享订阅在下发qos2 消息时,无论什么情况禁止转发给其它订阅者;下发qos1 消息时,如果session进程挂掉,应该把消息转给其它订阅用户;但是emq文档用的 shared_dispatch_ack_enabled = true| false配置,qos1 和 qos2 统一策略 都可以把消息转给其它订阅用户或者都不可以把消息转给其它订阅者
    mqtt 文档介绍
If the Server is in the process of sending a QoS 2 message to its chosen subscribing Client and the connection to the Client breaks before delivery is complete, the Server MUST complete the delivery of the message to that Client when it reconnects [MQTT-4.8.2-4] as described in section If the Client's Session terminates before the Client reconnects, the Server MUST NOT send the Application Message to any other subscribed Client [MQTT-4.8.2-5].

 If the Server is in the process of sending a QoS 1 message to its chosen subscribing Client and the  connection to that Client breaks before the Server has received an acknowledgement from the Client,
3155 the Server MAY wait for the Client to reconnect and retransmit the message to that Client. If the Client'sSession terminates before the Client reconnects, the Server SHOULD send the Application  Message to another Client that is subscribed to the same Shared Subscription. It MAY attempt to  send the message to another Client as soon as it loses its connection to the first Client.

文档链接mqtt shared_subscription

  1. 即便按照目前emq的标准,当配置 shared_dispatch_ack_enabled = true,下发共享订阅 qos1 和qos2 消息时,目前的代码没有收到ack 时就给emqx_shared_sub进程通知(原因emqx_shared_sub 进程给session进程发数据后,session进程回复,然后马上挂掉),导致实际上数据会丢失,并没有真正把消息转给其它订阅者

  2. 即便按照目前emq的标准,当配置 shared_dispatch_ack_enabled = true,下发共享订阅 qos1 和qos2 消息时,目前的代码没有收到ack 时就给emqx_shared_sub进程通知(原因emqx_shared_sub 进程给session进程发数据后,session进程回复,然后马上挂掉),导致实际上数据会丢失,并没有真正把消息转给其它订阅者

  3. 共享订阅用 当前session进程去send 并且 receive 消息,另一方面假如改成等待session进程收到 ack 后再给当前session进程发消息,假如一直没有ack回复,会导致session 进程阻塞,应该spawn 一个进程处理

1 个赞

您好,我刚刚看了代码,确实有您说的问题,十分感谢您的意见,我们这边后续会进行改进

您好, 请问现在这个问题2解决了吗?

Nice catch!! @597555230 非常棒的问题

我们最近正在修复这个问题 see: feat(shared): redispatch to another shared sub, when no ACK received by gsychev · Pull Request #7807 · emqx/emqx · GitHub

@597555230 @qihanzhou 以上问题我们已经在 EMQX 5.0.9 中修复。