Explorar el Código

fix(device): ensure broken connections are not reused

When we have a persistent connection, retries were not resetting the
connection until reaching the backoff limit. Close the connection immediately,
as a connection that is giving errors is of no use, and it is better to
retry using a new connection.

Possibly related to #4884 and/or #4885. Although these issues have gotten worse
since 2026.4.0 which reduced the heartbeat rate, keeping one-way receives in
between, the logs are showing the issues happen on the heartbeats, so it is not
clear that the lack of heartbeat is causing the issue.
Jason Rumney hace 2 meses
padre
commit
9cac985d1d
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      custom_components/tuya_local/device.py

+ 5 - 1
custom_components/tuya_local/device.py

@@ -671,7 +671,11 @@ class TuyaLocalDevice(object):
                     i,
                     i,
                     connections,
                     connections,
                 )
                 )
-
+                # Ensure we have a fresh connection for the next attempt
+                self._api.set_socketPersistent(False)
+                if self._api.parent:
+                    self._api.parent.set_socketPersistent(False)
+                    
                 if i + 1 == connections:
                 if i + 1 == connections:
                     self._reset_cached_state()
                     self._reset_cached_state()
                     self._api_working_protocol_failures += 1
                     self._api_working_protocol_failures += 1