2
client = MosquittoClient(clientId: "client1")
client?.delegate = self
client?.port = 1883
client?.host = "someIPAddress"
client!.cleanSession = false
client?.connect()

libmosquitto is a objective c library that is bridged over into a swift project. So after setting the cleanSession to false, i am still unable to set up a persistent subscription or receive message when offline.

1 Answers1

0

Setting a cleanSession = false will not do your job.. If you want to receive a message after reconnection it will require QOS..

By default qos of message and subscribe is 0 which will not guarantee that message will be delivered to the offline clients..

You need to do 2 things:
1. When you subscribe for a topic subscribe it with QOS 1 or 2.
2. When you publish a message that you want to be delivered to offline clients send with qos 1 or 2.

Nd also use same client IDs for connecting.. If you want that the messages also be received by new clients that use retain=true while publishing message

rohan dhama
  • 56
  • 2
  • 10