mosquitto-users team mailing list archive
-
mosquitto-users team
-
Mailing list archive
-
Message #00012
Re: mosquitto_sub and clean session flag disable
Hi Stefano,
> I know I'm missing something. I'm trying to use the "no clean session"
> feature:
> On one terminal:
>
> stefanoco@stefanocopc:~$ mosquitto_sub -c -i "6748" -v -t "diag/#"
...
> stefanoco@stefanocopc:~$ mosquitto_pub -i "7748" -q 1 -t "diag/par01" -m
...
> Everything ok. Now, having used the "-c" flag in sub, I expect that if I
> kill mosquitto_sub, then publish more messages with above lines, and the
> launch again mosquitto_sub I get the messages in queue. I'm getting
> nothing... is there anything I should look after in mosquitto.conf?
The problem here is that you're not subscribing with QoS>0. The spec
says that only messages with QoS>1 should be queued. Your messages are
being published with QoS=1 so you have half of it solved, you just
need to subscribe at QoS=1 as well.
The next version of mosquitto offers the ability to have messages with
QoS=0 queued as well, but as this is a feature beyond the spec it
isn't enabled by default and probably shouldn't be relied upon.
> By the way: using the same id for pub/sub causes sub to exit suddenly (I
> know I shouldn't but this is not an intended behaviour I guess?)
The client id is unique across the broker so if a client with a
duplicate id connects the oldest client is disconnected. This allows a
client who has lost their connection to reclaim their id for example.
The unique client id is required for the clean session to work.
Cheers,
Roger
References