接收离线消息mqtt [英] Receive offline messages mqtt

查看:670
本文介绍了接收离线消息mqtt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mosquitto作为代理,并使用paho(python)作为客户端.我正在尝试使订户接收脱机消息.

I'm using mosquitto as broker and paho(python) as client. I'm trying to make subscriber to receive offline messages.

为此,我进行了以下更改:

For that I made following changes:

  • 固定的客户ID
  • 第2级质量

但是,订阅者仍然无法接收消息.

but, still the subscriber is not able to receive messages.

有什么帮助吗?

谢谢, 拉胡尔

推荐答案

为了使您的客户端成为持久客户端,并在脱机时接收发送到主题的消息,您需要满足以下条件:

In order to have your client as a durable client and receive messages that were sent to topics when it was offline, you need to meet the following criteria:

  1. 固定的客户端ID(已完成)
  2. 始终与clean_session = False连接
  3. 必须使用QoS> 0进行订阅
  4. 发布的消息必须具有QoS> 0

我最常犯的错误是忘记第3点和第4点之一,所以我要以QoS = 0进行发布或以QoS = 0进行订阅,这两种情况都会导致消息无法存储.

The mistake that I make most frequently is to forget either one of points 3 and 4, so I'm publishing with QoS=0 or subscribing with QoS=0, either of which would cause messages not to be stored.

您还可以查看queue_qos0_messages选项,以告诉代理也存储QoS = 0消息.请注意,这是实现细节,可能特定于蚊子.

You could also look at the queue_qos0_messages option to tell the broker to store QoS=0 messages as well. Note that this is an implementation detail that may be specific to mosquitto.

这篇关于接收离线消息mqtt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆