Cereal2nd / domogik-plugin-velbus

Domogik velbus plugin
Other
2 stars 1 forks source link

Recover from connection loss? #4

Open jschaeke opened 6 years ago

jschaeke commented 6 years ago

Hi, Lately I need to restart the plugin as it doesn't respond anymore (no communication to and from the velbus devices). I am using a connection to velbusd on another machine so I suspect a transmission issue. I haven't investigated code yet but should it recover from connection issues and if not is a library like https://testpypi.python.org/pypi/watchedserial a solution?

Cereal2nd commented 6 years ago

I like the idea,

if you want you can implement this :) otherwise i'll look into it in the coming weeks

Maikel

On Mon, Oct 23, 2017 at 1:34 PM Jeroen Schaeken notifications@github.com wrote:

Hi, Lately I need to restart the plugin as it doesn't respond anymore. I am using a connection to velbusd on another machine so I suspect a transmission issue? Haven't investigated code yet but should it recover from connection issues, of not is library like https://testpypi.python.org/pypi/watchedserial a solution?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Cereal2nd/domogik-plugin-velbus/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ADiy8b706sa4mA4b6L5HaYyc2ipNB5PTks5svHnDgaJpZM4QCsaf .

jschaeke commented 6 years ago

Thanks, will move it to my ever growing Todo list too ;)

jschaeke commented 6 years ago

I've looked at the code; I am using a socket connection so watchedSerial won't help me. The following might do the trick: https://stackoverflow.com/questions/15870614/python-recreate-a-socket-and-automatically-reconnect

Cereal2nd commented 6 years ago

implemented in develop, if we lose the connection we try to reconnect once after 10 seconds

jschaeke commented 6 years ago

Thanks, and indeed it tries to reconnect once ... although this will probably fix the issue I encounter most of the time now (I confirmed it works); it won't be a final solution if the connectivity is lost for longer time (e.g. the rpi acting as velbus gateway reboots > 10 sec offline).

Cereal2nd commented 6 years ago

this is a start, later on i hope to implement some sort of incremental backoff

1- try to reconnect 2- if fails wait timeout (10 sec) 3- try reconnect 4- if fails wait timeout*2(20 sec) ...

so this until we reach a certain threshold