CocoaMQTT
CocoaMQTT copied to clipboard
CocoaMQTT disconnects when phone screen is put to sleep and waken up again. Autoreconnect does not trigger.
Steps to reproduce
- create CocoaMQTT instance
- turn on autoreconnect
- connect to broker
- start sending/receiving messages
- turn phone screen off.
- turn phone screen on.
- notice MQTT disconnects with error code 7 (server closed connection).
- notice that autoreconnect does not trigger
Current workaround
- in the didDisconnect delegate method, I call mqtt.connect() again.
- in the connection ack delegate method, I check if ack is accept, otherwise close the connection.
We will fix it in the next release version
@leeway1208 Any updates here?
Please try the latest version.
CocoaMQTT V3.1.1 (Release 2.0.9) IOS 16 It still happens.
I use reconnect to solve this problem after active application. NotificationCenter.default.addObserver(self, selector: #selector(reConnectAll), name: UIApplication.didBecomeActiveNotification, object: nil)
In v2.1.5 the client reconnects successfully but previously subscribed topics are not received anymore. Do I have to resubscribe?