novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 463 forks source link

MQTTSessionManager gets stuck in "closing" state after calling disconnect without a connection #540

Open mciuba opened 4 years ago

mciuba commented 4 years ago

Short description

When disconnect is called on MQTTSessionManager in "starting" state (that is, before starting any connection), it gets stuck in "closing" state indefinitely.

Environment

Steps to reproduce

  1. Initialize MQTTSessionManager
  2. Call disconnect(disconnectHandler:)) on it (without calling connect first - the manager is in "starting" state)

Expected behaviour

Manager's state eventually changes to "closed", or it remains in "starting" state.

Actual behaviour

Manager changes state to "closing" and never transitions to "closed". Then the next connect call will not work - the manager will remain in "closing" state (probably because of this check: https://github.com/novastone-media/MQTT-Client-Framework/blob/33e06af6ae0c5d93f51191fdd0c2d8453c5ddfa9/MQTTClient/MQTTClient/MQTTSessionManager.m#L335).

Other information

I think calling disconnect in "starting" / "closed" state should be a no-op (do nothing).