Reputation: 4767
I am unable to receive messages on first time connection. for in more detail,user A
is connected and publishing messages,but user B
is not connected to that topic.So when user B
will connect,he will not get any message from user A because there is first time connection b/w user a
and user b
.
How we can resolve this issue ?
Thanks
Upvotes: 0
Views: 532
Reputation: 11608
A principle of pub/sub is that the publisher and subscriber are decoupled, so you shouldn't really be thinking in terms of user a
being connected to user b
.
If you want a client to receive messages when they are not connected (leaving retained messages to one side), the only way to do this is:
cleansession=false
queue_qos0_messages
option)cleansession=false
To test this, try:
mosquitto_sub -i prajbot-singh -h test.mosquitto.org -t prajbot-singh -c -q 1
Then quit from mosquitto_sub and run:
mosquitto_pub -h test.mosquitto.org -t prajbot-singh -m hello -q 1
And run mosquitto_sub again:
mosquitto_sub -i prajbot-singh -h test.mosquitto.org -t prajbot-singh -c -q 1
Upvotes: 1