kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
303 stars 59 forks source link

FritzMonitor connection problems #179

Closed jerome992 closed 1 year ago

jerome992 commented 1 year ago

Hello,

the FritzMonitor class has the following problems: (1) the reconnection is not working, because it is not possible to call a second time the connect function ( except if a socket timeout has occurred) (2) the variable raw_data is not reset in the loop and can contain data from the previous round

For every reconnect inside the monitoring thread, a new socket must be created. In this case, a few tests are no longer working, because they are using a socket created ouside of the monitoring thread.

A possible solution can be found with same failing tests can be found here: https://github.com/jerome992/fritzconnection/commit/ae47eb6f3fb0ee3cc81d524746b91caf287430ce

kbr commented 1 year ago

Thank you for reporting. Will go into this.

kbr commented 1 year ago

I'm in this now and yes, a failed socket should get discarded and replaced by a new one.

Tests are failing in your case because test-socket injection no longer works on your mentioned code changes. This must be redesigned or adapted in your changes to keep tests running.

As far as I can see raw_data don't need a reset. It's an immutable datatype and assigned with valid data or no content on a lost connection. I don't see any possible side-effects providing the same raw_data multiple times to the EventReporter. Do you have a test that proves otherwise?

kbr commented 1 year ago

Changes according to (1): create new socket on lost connection. Changed mock-socket injection dependency to keep tests running. Fix will be in version 1.12.0

Feel free to reopen or create a new issue if there was something missing.