nlrb / com.tclcode.otgw

OpenTherm Gateway application for Homey
https://apps.athom.com/app/com.tclcode.otgw
10 stars 3 forks source link

Connection dropped #1

Closed denniedegroot closed 8 years ago

denniedegroot commented 8 years ago

I noticed that Homey stopped logging OTGW data to insights and found out that the socket connection to the OTGW was dropped. When clicking on "Save network settings" the connection was re-established and Homey started logging again. Until now it only happend once but is it possible to maybe implement some kind of reconnect on connection timeout? I think more users will experience this when for example they have a bad wifi network.

nlrb commented 8 years ago

Good point, will add that, thanks!

denniedegroot commented 8 years ago

Thank you for this great app!

nlrb commented 8 years ago

You're welcome. Let me know if you find other issues or in case of feature requests.

nlrb commented 8 years ago

It should automatically re-connect in version 0.5.0. Can you check? I have difficulty testing the situation.

denniedegroot commented 8 years ago

Unfortunately it is not fixed. I tested it by powering off my wifi router. I looked at the code and see you introduced a "reconnectTimer" variable which is cleared when there is a connection but then is never checked again? So when the connection drops how does it re-connect?

nlrb commented 8 years ago

When the clients stops, there is a 'close' event. This calls a new openComm. At the stat of that function there the interval timer is set (reconnectTimer), which will check every 3 seconds.

When I try here (cable connection) by unplugging the Ethernet cable, the client stays active. So when I plug it in again, the code just continues. I've made a special test case that closes the client connection and then the re-connect works.

In your case, when powering off the router, I guess more happens - as Homey will also lose connection. Does it come back with the same IP address.

Otherwise can you set the variable 'debugOn' to true and provide me the log output?

denniedegroot commented 8 years ago

Ok I did some more testing and found out that the client.close is not called when I disconnect the OTGW. So that's why it is not trying to reconnect.

Edit: I can't test the behavior of Homey because then I won't be able to see the logging.

nlrb commented 8 years ago

Ok, I'll add a timeout for 1 minute.

denniedegroot commented 8 years ago

Thanks! It works perfect :)