如何在蚊子中禁用MQTT重复消息

发布于 2025-01-18 01:25:33 字数 4969 浏览 1 评论 0原文

我的机器运行Ubuntu 18.04我已经安装了蚊子。以下是其Mosquitto.conf& bridge.conf文件。

`mosquitto.conf`

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

以下是现在从Python代码的桥梁文件,

connection iothub-bridge
log_type all
address ttpvluk.azure-devices.net:8883
remote_username ttpvluk.azure-devices.net/TX-S2-PVL-0E01
remote_password SharedAccessSignature sr=ttpvluk.azure-devices.net&sig=ylwqmY3N5%2FbnOdaNok4p90pTWg%3D&se=253402280999.36&skn=iothubowner
remote_clientid TX-S2-PVL-0E01
bridge_cafile /etc/ssl/certs/ca-certificates.crt
try_private false
cleansession false
start_type automatic
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
notifications false
keepalive_interval 36000
autosave_interval 30

topic # out 2 devices/TX-S2-PVL-0E01/messages/events/ devices/TX-S2-PVL-0E01/messages/events/
topic # in 2 devices/TX-S2-PVL-0E01/messages/devicebound/ devices/TX-S2-PVL-0E01/messages/devicebound/

我将几个数据发送给了Mosquitto Broker,我正在使用Azure Iot Device Explorer进行检查。但是我只是继续使用DUP TRUE检查收到第一条消息。以下是屏幕截图

“在蚊子日志中inter

在蚊子日志中,我可以看到它一次又一次地发送数据我的Python代码停止。

1648738705: Bridge local.TX-S2-PVL-0E01 doing local SUBSCRIBE on topic devices/TX-S2-PVL-0E01/messages/events/#
1648738705: Connecting bridge (step 1) iothub-bridge (ttpvluk.azure-devices.net:8883)
1648738705: Connecting bridge (step 2) iothub-bridge (ttpvluk.azure-devices.net:8883)
1648738705: Bridge TX-S2-PVL-0E01 sending CONNECT
1648738706: Received CONNACK on connection local.TX-S2-PVL-0E01.
1648738706: Bridge local.TX-S2-PVL-0E01 sending UNSUBSCRIBE (Mid: 974, Topic: devices/TX-S2-PVL-0E01/messages/events/#)
1648738706: Bridge local.TX-S2-PVL-0E01 sending SUBSCRIBE (Mid: 975, Topic: devices/TX-S2-PVL-0E01/messages/devicebound/#, QoS: 2, Options: 0x00)
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m10, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m11, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m12, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m13, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m14, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m15, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m16, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m19, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m20, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m21, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m22, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m23, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m24, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m27, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m28, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m29, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m30, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m31, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m32, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m35, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Received UNSUBACK from local.TX-S2-PVL-0E01
1648738706: Received SUBACK from local.TX-S2-PVL-0E01

我该如何解决这个问题?

I have machine running Ubuntu 18.04 where I have installed mosquitto. Below is its mosquitto.conf & bridge.conf file.

`mosquitto.conf`

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Below is the bridge file

connection iothub-bridge
log_type all
address ttpvluk.azure-devices.net:8883
remote_username ttpvluk.azure-devices.net/TX-S2-PVL-0E01
remote_password SharedAccessSignature sr=ttpvluk.azure-devices.net&sig=ylwqmY3N5%2FbnOdaNok4p90pTWg%3D&se=253402280999.36&skn=iothubowner
remote_clientid TX-S2-PVL-0E01
bridge_cafile /etc/ssl/certs/ca-certificates.crt
try_private false
cleansession false
start_type automatic
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
notifications false
keepalive_interval 36000
autosave_interval 30

topic # out 2 devices/TX-S2-PVL-0E01/messages/events/ devices/TX-S2-PVL-0E01/messages/events/
topic # in 2 devices/TX-S2-PVL-0E01/messages/devicebound/ devices/TX-S2-PVL-0E01/messages/devicebound/

Now from python code I sent few data to mosquitto broker and I am checking it on azure iot device explorer. But I just keep getting the 1st message with dup true check. Below is the screenshot

enter image description here

In the mosquitto logs as well, I can see that it sending data again and again while my python code is stop.

1648738705: Bridge local.TX-S2-PVL-0E01 doing local SUBSCRIBE on topic devices/TX-S2-PVL-0E01/messages/events/#
1648738705: Connecting bridge (step 1) iothub-bridge (ttpvluk.azure-devices.net:8883)
1648738705: Connecting bridge (step 2) iothub-bridge (ttpvluk.azure-devices.net:8883)
1648738705: Bridge TX-S2-PVL-0E01 sending CONNECT
1648738706: Received CONNACK on connection local.TX-S2-PVL-0E01.
1648738706: Bridge local.TX-S2-PVL-0E01 sending UNSUBSCRIBE (Mid: 974, Topic: devices/TX-S2-PVL-0E01/messages/events/#)
1648738706: Bridge local.TX-S2-PVL-0E01 sending SUBSCRIBE (Mid: 975, Topic: devices/TX-S2-PVL-0E01/messages/devicebound/#, QoS: 2, Options: 0x00)
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m10, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m11, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m12, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m13, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m14, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m15, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m16, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m19, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m20, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m21, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m22, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m23, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m24, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q2, r0, m27, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m28, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m29, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m30, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m31, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m32, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Sending PUBLISH to local.TX-S2-PVL-0E01 (d1, q1, r0, m35, 'devices/TX-S2-PVL-0E01/messages/events/', ... (169 bytes))
1648738706: Received UNSUBACK from local.TX-S2-PVL-0E01
1648738706: Received SUBACK from local.TX-S2-PVL-0E01

How can I resolve this issue.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮华 2025-01-25 01:25:33

Azure IoT 中心不支持 QOS 2

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#sending-device-to-cloud-messages

您已将新娘配置为使用 QOS 2 发送消息

Azure IoT Hub does NOT support QOS 2

https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#sending-device-to-cloud-messages

You have configured the bride to send messages with QOS 2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文