diff --git a/mqtt.lua b/mqtt.lua index e76c89d..0338cbc 100644 --- a/mqtt.lua +++ b/mqtt.lua @@ -142,6 +142,11 @@ function MqttClient:connect (username, password) return err end + local _, err = self.conn:flush() + if err ~= nil then + return err + end + self.is_connecting = true return nil @@ -163,6 +168,11 @@ function MqttClient:disconnect (reason) return err end + local _, err = self.conn:flush() + if err ~= nil then + return err + end + self.is_connecting = false self.is_connected = false