chamberlain2007 / aprilaire-ha

A custom component for Home Assistant to interact with Aprilaire thermostats.
MIT License
12 stars 5 forks source link

Plugin gets into a tight connection loop #8

Closed nberardi closed 1 year ago

nberardi commented 1 year ago

The plugin gets into a tight connection loop when it cannot connect and ends up overwhelming the device. I discovered this with the proxy client that I messaged you about.

In the below logs 10.10.0.24 is my thermostat, and 10.10.0.52 is my HA box. You can see how often the HA box is trying to reconnect to establish a connection.

[2023-02-07T22:52:58.707Z] 10.10.0.24 error Error: connect EHOSTUNREACH 10.10.0.23:8000
[2023-02-07T22:52:58.722Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.728Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.740Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.747Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.765Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.909Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.934Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.943Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.964Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.973Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.989Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:58.997Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.018Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.025Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.048Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.054Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.076Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.086Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.102Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.108Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.127Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.135Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.153Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.161Z] 10.10.0.24: disconnected please reconnect to try again
[2023-02-07T22:52:59.164Z] 10.10.0.24 connected
[2023-02-07T22:52:59.166Z] 10.10.0.24 disconnected
[2023-02-07T22:52:59.181Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.189Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.212Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.218Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.237Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.244Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.257Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.264Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.278Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.284Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.297Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.303Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.328Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.341Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.346Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.357Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.365Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.378Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.388Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.400Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.406Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.419Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.425Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.435Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.449Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.458Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.461Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.472Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.482Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.492Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.500Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.509Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.523Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.527Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.535Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.545Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.554Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.568Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.577Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.586Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.595Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.603Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.614Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.623Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.634Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.642Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.651Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.661Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.672Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.683Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
[2023-02-07T22:52:59.692Z] ::ffff:10.10.0.52 too many connections, please wait 1 second before trying again
chamberlain2007 commented 1 year ago

@nberardi I am not planning to support third party proxies like this. This wouldn't happen on a real device, which already handles a 10 second delay between attempts to reconnect. Your proxy that you developed is probably accepting the connection and then dropping it, which triggers a different flow.

nberardi commented 1 year ago

This tool was developed originally to log the connection information only. It was purely by accident I discovered this issue, while trying to work out why the device connection was dying on startup when connected to the HA plugin.

The plugin was not handling a 10 second delay, on startup while the thermostat was booting up. And the spamming of the connection, causes it to go back into the state where it doesn’t accept a connection.

chamberlain2007 commented 1 year ago

@nberardi FYI, I think I see where the issue is, and it will be fixed in the next release. Your proxy did a thing where it accepted and dropped the connection, which I hadn't seen happen before. The logic didn't properly handle the case where a disconnect would happen in that state. I'm going to reopen this, it should be fixed in general with the next release.

nberardi commented 1 year ago

That is great to hear regarding the fix.

That connecting and dropping is something I have observed and logged on my 8840 above as well. It seems to happen when the thermostat gets overwhelmed with connections.

[2023-02-07T22:52:59.164Z] 10.10.0.24 connected
[2023-02-07T22:52:59.166Z] 10.10.0.24 disconnected

The proxy’s logic is whenever the thermostat would disconnect, I would send a disconnect to the client as well.

chamberlain2007 commented 1 year ago

@nberardi The change described has been released in 0.5.0. Thanks!