← Back to team overview

mosquitto-users team mailing list archive

Qos and receiving messages

 

Hi all,

I'm testing my Mosquitto setup and I want to make sure that messages that
are sent to mosquitto will be picked up by a subscriber, even if a
subscriber was disconnected for a while, but I cannot seem to get this to
work, currently I listen to mosquitto (on ubuntu) using this
command:*mosquitto_sub -d -q 1 -t hello/world
*

and I am sending periodic messages using the following python script:

*import mosquitto*
*import os*
*import time*
*
*
*broker = "127.0.0.1"*
*port = 1883*
*
*
*mypid = os.getpid()*
*client_uniq = "pubclient_"+str(mypid)*
*mqttc = mosquitto.Mosquitto(client_uniq)*
*
*
*mqttc.connect(broker, port, 60, True)*
*
*
*mqttc.publish("hello/world", "hi")*
*
*
*while mqttc.loop() == 0:*
*        msg = "test message " + time.ctime()*
*        mqttc.publish("hello/world", msg, 1)*
*        print "The following message was published: " + msg*

My goal is that even if I disconnect the subscription for a while that all
the messages that are sent to mosquitto  in the mean time will be saved and
sent to a subscribing client as soon as it shows up again.

I've tried to do this with qos=2 in the publish script, and that does seem
to send the oldest message in the queue to the subscriber, but only at the
interval at which new messages are arriving, and once I stop publishing,
the subscriber stops receiving, even though there are still several
messages which have not been received.

Am I missing something obvious?

Attached my .conf file.

Kind Regards,

Jeroen Netten

Attachment: mosquitto.conf
Description: Binary data


Follow ups