in mqtt qos1 i want to set dup flag true i dont know im not setting up dup falg can anybody explain this

huangapple go评论59阅读模式
英文:

in mqtt qos1 i want to set dup flag true i dont know im not setting up dup falg can anybody explain this

问题

bool dup = true;

// 以QoS 1发布消息
rc = mosquitto_publish(mosq, &mid, topic, strlen(message), message, 1, false);
if (rc != MOSQ_ERR_SUCCESS)
{
fprintf(stderr, "发布消息失败:%s\n", mosquitto_strerror(rc));
mosquitto_disconnect(mosq);
return;
}

broker没有提供

1684126876:来自auto-FF3BAA6D-E659-460B-7332-244382A86BDE的PUBLISH消息(d0,q1,r0,m1,'example/topic',...(12字节))
1684126876:向auto-FF3BAA6D-E659-460B-7332-244382A86BDE发送PUBACK(m1,rc0)

我想要d1而不是d0。

英文:
bool dup = true;

// Publish the message with QoS 1
rc = mosquitto_publish(mosq, &mid, topic, strlen(message), message, 1, false);
if (rc != MOSQ_ERR_SUCCESS)
{
    fprintf(stderr, "Failed to publish message: %s\n", mosquitto_strerror(rc));
    mosquitto_disconnect(mosq);
    return;
}

broker not giving

1684126876: Received PUBLISH from auto-FF3BAA6D-E659-460B-7332-244382A86BDE (d0, q1, r0, m1, 'example/topic', ... (12 bytes))
1684126876: Sending PUBACK to auto-FF3BAA6D-E659-460B-7332-244382A86BDE (m1, rc0)

i want d1 instead of d0

答案1

得分: 1

你不需要手动设置dupe标志,如果客户端需要在客户端断开连接之前重新发送消息,Mosquitto客户端库(或任何其他MQTT客户端库)会为您执行此操作,因为QOS1握手尚未完成。

在这种情况下,当客户端重新连接时,它会设置dupe标志并重新发送消息。

这不是由最终用户代码设置的。

英文:

You do not manually set the dupe flag, the mosquitto client library (or any other MQTT client library) does this for you if the client needs to resend the message because the QOS1 handshake did not complete before the client was disconnected.

In that case when the client reconnects it will set the dupe flag and resend the message.

It is not something the end user code sets.

huangapple
  • 本文由 发表于 2023年5月15日 15:28:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251777.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定