flightonary / Moscapsule

MQTT Client for iOS written in Swift
MIT License
273 stars 69 forks source link

Autoreconnect stall #56

Open buganini opened 7 years ago

buganini commented 7 years ago

Autoreconnect stops when I

  1. enable airplane mode
  2. onDisconnectCallback (KeepAlive_Timeout)
  3. onDisconnectCallback (Disconnect_Requested)
  4. disable airplane mode

Or sometimes it just stops after disconnection with MOSQ_ERRNO.

Then I set mqttReconnOpts=nil and call reconnect() in onDisConnectCallback, but connection is never made after Disconnect_Requested, so I changed it to disconnect() and reconnect(), this is power consumptive so I changed it to trigger disconnect()/reconnect() with a watchdog timer instead of in onDisConnectCallback. This works in most of time but once or twice a day, I get infinite Disconnect_Requested.

Finally, renew MQTTClient instance in onDisConnectCallback and watchdog timer emulate reconnection, but the session is of course lost.

I'm using pod 'Moscapsule', :git => 'https://github.com/flightonary/Moscapsule.git' pod 'OpenSSL-Universal', '~> 1.0.1.18' on iOS 10.

Any suggestion?

AlexIzh commented 7 years ago

Did you try to use latest master branch version?

buganini commented 7 years ago

Yes, I am using latest master branch.