emqx / CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
https://www.emqx.com/en
Other
1.6k stars 422 forks source link

The cleanSession = false and iOS background model #189

Open eeh opened 6 years ago

eeh commented 6 years ago

Hi,

First of all, thanks for providing a great MQTT client! Works really nice.

I have however, stumbled upon a potential issue...

I connect to my mqtt broker like this:

let clientID = "\(UIDevice.current.identifierForVendor!.uuidString)-\(Properties.applicationId)"
mqttInstance = CocoaMQTT(clientID: clientID, host: Properties.mqttHost, port: 1883)
mqttInstance.keepAlive = 60
mqttInstance.delegate = self
mqttInstance.autoReconnect = true
mqttInstance.autoReconnectTimeInterval = 1
mqttInstance.cleanSession = true

Then I subscribe to some topics (with qos1).

All is good.

Now, I lock the phone, and when I subsequently unlock the phone, all subscriptions are lost. This behavior differs from other implementations, for instance mqtt.js which delivers qos1+ messages after reconnecting, although I am not sure what is the correct behavior...

Case in point for my use-case is the need for resetting the server-side session for some users which have to wide persistent subscriptions...

Thanks for any input on this!

boboxiaodd commented 6 years ago

mqttInstance.cleanSession = false

aiden-leong commented 6 years ago

facing same problem When I lock and then unlock, I can't send/receive messages. Any workaround?

HJianBo commented 5 years ago

Hi guys, we'll fix the iOS background model in the v1.3.0.