CocoaMQTT
CocoaMQTT copied to clipboard
Manual disconnection did not work as expected
I call mqtt.disconnect
,but it still reconnect.I found the variable is_internal_disconnected
is always true.
public func disconnect() {
is_internal_disconnected = false
internal_disconnect()
}
/// Disconnect unexpectedly
func internal_disconnect() {
is_internal_disconnected = true
send(FrameDisconnect(), tag: -0xE0)
socket.disconnect()
}
And the automatic reconnection logic doesn't look right.
if !autoReconnect{
guard !is_internal_disconnected else {
return
}
}
guard autoReconnect else {
return
}
The above code makes the is_internal_disconnected
variable meaningless.As I understand it, if I disconnect from the outside, it should not automatically reconnect.
I submitted the pr #466 to fix the problem.
Thank you for your support.😄
Trying to use mqtt!.autoReconnect = false. Is it work?
It's ok.But I think external disconnection and internal disconnection should be different behaviours. And the parameter is_internal_disconnected should work.
@ckfear Yes. you are right. I misunderstood. Thank you for your contribution!