Просмотр исходного кода

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 2 месяцев назад
Родитель
Сommit
9cac985d1d
1 измененных файлов с 5 добавлено и 1 удалено
  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,
                     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:
                     self._reset_cached_state()
                     self._api_working_protocol_failures += 1