CocoaMQTT icon indicating copy to clipboard operation
CocoaMQTT copied to clipboard

CocoaMQTT disconnects when phone screen is put to sleep and waken up again. Autoreconnect does not trigger.

Open BrentMifsud opened this issue 4 years ago • 5 comments

Steps to reproduce

  1. create CocoaMQTT instance
  2. turn on autoreconnect
  3. connect to broker
  4. start sending/receiving messages
  5. turn phone screen off.
  6. turn phone screen on.
  7. notice MQTT disconnects with error code 7 (server closed connection).
  8. notice that autoreconnect does not trigger

Current workaround

  1. in the didDisconnect delegate method, I call mqtt.connect() again.
  2. in the connection ack delegate method, I check if ack is accept, otherwise close the connection.

BrentMifsud avatar Oct 07 '20 17:10 BrentMifsud

We will fix it in the next release version

leeway1208 avatar Nov 10 '21 10:11 leeway1208

@leeway1208 Any updates here?

vadym-kozak avatar Dec 01 '22 17:12 vadym-kozak

Please try the latest version.

leeway1208 avatar Dec 02 '22 00:12 leeway1208

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)

hakama99 avatar Dec 27 '22 09:12 hakama99

In v2.1.5 the client reconnects successfully but previously subscribed topics are not received anymore. Do I have to resubscribe?

tomassliz avatar Jul 19 '23 14:07 tomassliz