dc297 / mqttclpro

MQTT Client for android with tasker support
MIT License
97 stars 30 forks source link

Tasker plugin event "Connection Lost", could be improved I think :) #54

Closed gemboot closed 6 years ago

gemboot commented 6 years ago

Hello,

First of all, thank you for this great app, I have tried many other MQTT clients and I must say this one is by far the best around, and I mean it ! ;)

Back to the "possible" issue, I have setup a task with Tasker that alerts me whenever the connection to the broker is lost, it works well, but when the connection to the broker is re-established, I get the "Connection Lost" notification again, this leads me to think that the event "Connection Lost" works for both states, ie. when the connection is lost and when it's recovered, is it a desired behavior ? I think it would be better to add another event, for example "Connection Recovered", this way we will be able to differentiate when the connection is lost or recovered.

Any thoughts on this ?

Thank you again ! ;)

dc297 commented 6 years ago

Hey, thanks for using the app :)

Ideally, the connection lost event should not be sent when we reconnect. Let me take a look into what might be causing the issue.

Cheers! Deepeesh

gemboot commented 6 years ago

Hey,

Thanks for checking this ;) you know what would be super cool ? if you could add a third event "Connection Recovered", this way it will be more complete ! One could set a notification sound when the connection is lost, and another one when it reconnects. would be suuuuuper nice to have ! :p

Many thanks again for your app ! ;)

dc297 commented 6 years ago

Hey hi

So I tried to simulate the issue but didn't succeed. I am attaching a video showing what I tried. Please tell me if you did something different.

https://drive.google.com/file/d/1wNtRfjJigo3lztOTnrzP-xQKHDapaBk3/view?usp=drivesdk

Let me look into adding an event for connection recovered.

Cheers! Deepesh

gemboot commented 6 years ago

Hi,

I can't read your video, it's not playing.... so I can't tell you... I have a question though, how do you test if the broker is alive or not ? do you send something similar to a "ping" to the broker every 1 second ? I'm just curious to know how this works, maybe I'm doing something wrong on my end.

Regarding the addition of the event "Connection Recovered", it's great !!! thank you in advance :p

gemboot commented 6 years ago

ok, I have double checked, and you're right it works as expected, the event is triggered only when the connection is lost, sorry for wasting your time about this... I think I had some internet micro disconnection and I haven't noticed it, and that made me think wrongly that this was a bug, really really sorry :(

Let's take the good from the bad, at least now we will have a third event for when the connection is recovered ;)

dc297 commented 6 years ago

Hey, the connection re-estlabished event is available in version 4.4.4.

Cheers!

gemboot commented 6 years ago

you're the man !! thank you ! works perfectly ;)

BTW, you didn't tell how you do your check to see if the broker is alive or not ? do you send something similar to a "ping" to the broker every 1 second ? I'm just curious to know how this works, (unless it's a secret and you don't want to tell :) I'll understand, no worries)

Thank you again

dc297 commented 6 years ago

Haha. No, it's not a secret. There's a keep-alive configuration which you can set for each broker. The application automatically sends a ping every keep-alive seconds. You may read about MQTT Keep-Alive here - https://www.hivemq.com/blog/mqtt-essentials-part-10-alive-client-take-over.

Sorry for the late reply. I have been a little busy lately.

Cheers! Deepesh